From 7a8469925e089cbd4d1a98137b6f08c601143853 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 24 May 2022 12:46:59 +0300 Subject: [PATCH] [DE PE SSE] Fix search restarting --- .../main/app/controller/Search.js | 23 ++++++++++++------- .../main/app/controller/Search.js | 23 ++++++++++++------- .../main/app/controller/Search.js | 21 ++++++++++------- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Search.js b/apps/documenteditor/main/app/controller/Search.js index e23c9a700..bee8c9b64 100644 --- a/apps/documenteditor/main/app/controller/Search.js +++ b/apps/documenteditor/main/app/controller/Search.js @@ -121,21 +121,28 @@ define([ this._state.useRegExp = checked; break; } - if (this._state.searchText !== '' && this.onQuerySearch()) { + if (this._state.searchText !== '') { this.hideResults(); - clearInterval(this.searchTimer); - this.searchTimer = undefined; - this.api.asc_StartTextAroundSearch(); + if (this.onQuerySearch()) { + if (this.searchTimer) { + clearInterval(this.searchTimer); + this.searchTimer = undefined; + } + this.api.asc_StartTextAroundSearch(); + } } }, 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; - if (this.onQuerySearch(type) && this.searchTimer) { + if (this.onQuerySearch(type) && (this.searchTimer || isReturnKey)) { this.hideResults(); - clearInterval(this.searchTimer); - this.searchTimer = undefined; + if (this.searchTimer) { + clearInterval(this.searchTimer); + this.searchTimer = undefined; + } if (this.view.$el.is(':visible')) { this.api.asc_StartTextAroundSearch(); } diff --git a/apps/presentationeditor/main/app/controller/Search.js b/apps/presentationeditor/main/app/controller/Search.js index 2d0db8205..dc540f244 100644 --- a/apps/presentationeditor/main/app/controller/Search.js +++ b/apps/presentationeditor/main/app/controller/Search.js @@ -118,21 +118,28 @@ define([ this._state.useRegExp = checked; break; } - if (this._state.searchText !== '' && this.onQuerySearch()) { + if (this._state.searchText !== '') { this.hideResults(); - clearInterval(this.searchTimer); - this.searchTimer = undefined; - this.api.asc_StartTextAroundSearch(); + if (this.onQuerySearch()) { + if (this.searchTimer) { + clearInterval(this.searchTimer); + this.searchTimer = undefined; + } + this.api.asc_StartTextAroundSearch(); + } } }, 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; - if (this.onQuerySearch(type) && this.searchTimer) { + if (this.onQuerySearch(type) && (this.searchTimer || isReturnKey)) { this.hideResults(); - clearInterval(this.searchTimer); - this.searchTimer = undefined; + if (this.searchTimer) { + clearInterval(this.searchTimer); + this.searchTimer = undefined; + } if (this.view.$el.is(':visible')) { this.api.asc_StartTextAroundSearch(); } diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js index 36ddf3c6f..1ee6a487a 100644 --- a/apps/spreadsheeteditor/main/app/controller/Search.js +++ b/apps/spreadsheeteditor/main/app/controller/Search.js @@ -157,11 +157,13 @@ define([ this._state.lookInFormulas = value; break; } - if (runSearch && this._state.searchText !== '' && this.onQuerySearch()) { + if (runSearch && this._state.searchText !== '') { this.hideResults(); - clearInterval(this.searchTimer); - this.searchTimer = undefined; - this.api.asc_StartTextAroundSearch(); + if (this.onQuerySearch()) { + this.searchTimer && clearInterval(this.searchTimer); + this.searchTimer = undefined; + this.api.asc_StartTextAroundSearch(); + } } }, @@ -192,12 +194,15 @@ define([ }, 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; - if (this.onQuerySearch(type) && this.searchTimer) { + if (this.onQuerySearch(type) && (this.searchTimer || isReturnKey)) { this.hideResults(); - clearInterval(this.searchTimer); - this.searchTimer = undefined; + if (this.searchTimer) { + clearInterval(this.searchTimer); + this.searchTimer = undefined; + } if (this.view.$el.is(':visible')) { this.api.asc_StartTextAroundSearch(); }