[DE PE SSE] Fix search restarting

This commit is contained in:
JuliaSvinareva 2022-05-24 12:46:59 +03:00
parent b68c5a7f0c
commit 7a8469925e
3 changed files with 43 additions and 24 deletions

View file

@ -121,21 +121,28 @@ define([
this._state.useRegExp = checked; this._state.useRegExp = checked;
break; break;
} }
if (this._state.searchText !== '' && this.onQuerySearch()) { if (this._state.searchText !== '') {
this.hideResults(); this.hideResults();
clearInterval(this.searchTimer); if (this.onQuerySearch()) {
this.searchTimer = undefined; if (this.searchTimer) {
this.api.asc_StartTextAroundSearch(); clearInterval(this.searchTimer);
this.searchTimer = undefined;
}
this.api.asc_StartTextAroundSearch();
}
} }
}, },
onSearchNext: function (type, text, e) { onSearchNext: function (type, text, e) {
if (text && text.length > 0 && (type === 'keydown' && e.keyCode === Common.UI.Keys.RETURN || type !== 'keydown')) { var isReturnKey = type === 'keydown' && e.keyCode === Common.UI.Keys.RETURN;
if (text && text.length > 0 && (isReturnKey || type !== 'keydown')) {
this._state.searchText = text; this._state.searchText = text;
if (this.onQuerySearch(type) && this.searchTimer) { if (this.onQuerySearch(type) && (this.searchTimer || isReturnKey)) {
this.hideResults(); this.hideResults();
clearInterval(this.searchTimer); if (this.searchTimer) {
this.searchTimer = undefined; clearInterval(this.searchTimer);
this.searchTimer = undefined;
}
if (this.view.$el.is(':visible')) { if (this.view.$el.is(':visible')) {
this.api.asc_StartTextAroundSearch(); this.api.asc_StartTextAroundSearch();
} }

View file

@ -118,21 +118,28 @@ define([
this._state.useRegExp = checked; this._state.useRegExp = checked;
break; break;
} }
if (this._state.searchText !== '' && this.onQuerySearch()) { if (this._state.searchText !== '') {
this.hideResults(); this.hideResults();
clearInterval(this.searchTimer); if (this.onQuerySearch()) {
this.searchTimer = undefined; if (this.searchTimer) {
this.api.asc_StartTextAroundSearch(); clearInterval(this.searchTimer);
this.searchTimer = undefined;
}
this.api.asc_StartTextAroundSearch();
}
} }
}, },
onSearchNext: function (type, text, e) { onSearchNext: function (type, text, e) {
if (text && text.length > 0 && (type === 'keydown' && e.keyCode === Common.UI.Keys.RETURN || type !== 'keydown')) { var isReturnKey = type === 'keydown' && e.keyCode === Common.UI.Keys.RETURN;
if (text && text.length > 0 && (isReturnKey || type !== 'keydown')) {
this._state.searchText = text; this._state.searchText = text;
if (this.onQuerySearch(type) && this.searchTimer) { if (this.onQuerySearch(type) && (this.searchTimer || isReturnKey)) {
this.hideResults(); this.hideResults();
clearInterval(this.searchTimer); if (this.searchTimer) {
this.searchTimer = undefined; clearInterval(this.searchTimer);
this.searchTimer = undefined;
}
if (this.view.$el.is(':visible')) { if (this.view.$el.is(':visible')) {
this.api.asc_StartTextAroundSearch(); this.api.asc_StartTextAroundSearch();
} }

View file

@ -157,11 +157,13 @@ define([
this._state.lookInFormulas = value; this._state.lookInFormulas = value;
break; break;
} }
if (runSearch && this._state.searchText !== '' && this.onQuerySearch()) { if (runSearch && this._state.searchText !== '') {
this.hideResults(); this.hideResults();
clearInterval(this.searchTimer); if (this.onQuerySearch()) {
this.searchTimer = undefined; this.searchTimer && clearInterval(this.searchTimer);
this.api.asc_StartTextAroundSearch(); this.searchTimer = undefined;
this.api.asc_StartTextAroundSearch();
}
} }
}, },
@ -192,12 +194,15 @@ define([
}, },
onSearchNext: function (type, text, e) { onSearchNext: function (type, text, e) {
if (text && text.length > 0 && (type === 'keydown' && e.keyCode === Common.UI.Keys.RETURN || type !== 'keydown')) { var isReturnKey = type === 'keydown' && e.keyCode === Common.UI.Keys.RETURN;
if (text && text.length > 0 && (isReturnKey || type !== 'keydown')) {
this._state.searchText = text; this._state.searchText = text;
if (this.onQuerySearch(type) && this.searchTimer) { if (this.onQuerySearch(type) && (this.searchTimer || isReturnKey)) {
this.hideResults(); this.hideResults();
clearInterval(this.searchTimer); if (this.searchTimer) {
this.searchTimer = undefined; clearInterval(this.searchTimer);
this.searchTimer = undefined;
}
if (this.view.$el.is(':visible')) { if (this.view.$el.is(':visible')) {
this.api.asc_StartTextAroundSearch(); this.api.asc_StartTextAroundSearch();
} }