From b68c5a7f0c0f75b3a5eb37bd204694a6133dd74e Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 20 May 2022 14:03:21 +0300 Subject: [PATCH] [DE PE SSE] Fix search panel after show --- apps/documenteditor/main/app/controller/Search.js | 7 ++++--- apps/presentationeditor/main/app/controller/Search.js | 7 ++++--- .../spreadsheeteditor/main/app/controller/LeftMenu.js | 4 ++-- apps/spreadsheeteditor/main/app/controller/Search.js | 11 ++++++----- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Search.js b/apps/documenteditor/main/app/controller/Search.js index 73c936b06..e23c9a700 100644 --- a/apps/documenteditor/main/app/controller/Search.js +++ b/apps/documenteditor/main/app/controller/Search.js @@ -303,7 +303,7 @@ define([ onApiGetTextAroundSearch: function (data) { if (this.view && this._state.isStartedAddingResults) { - if (data.length > 300) return; + if (data.length > 300 || !data.length) return; var me = this; me.resultItems = []; data.forEach(function (item, ind) { @@ -352,7 +352,7 @@ define([ viewport.searchBar.hide(); } - var text = findText || this.api.asc_GetSelectedText() || this._state.searchText; + var text = typeof findText === 'string' ? findText : (this.api.asc_GetSelectedText() || this._state.searchText); if (this.resultItems && this.resultItems.length > 0 && (!this._state.matchCase && text.toLowerCase() === this.view.inputText.getValue().toLowerCase() || this._state.matchCase && text === this.view.inputText.getValue())) { // show old results @@ -360,8 +360,9 @@ define([ } if (text) { this.view.setFindText(text); - } else if (text !== undefined) { + } else if (text !== undefined) { // panel was opened from empty searchbar, clear to start new search this.view.setFindText(''); + this._state.searchText = undefined; } this.hideResults(); diff --git a/apps/presentationeditor/main/app/controller/Search.js b/apps/presentationeditor/main/app/controller/Search.js index 6f06a098d..2d0db8205 100644 --- a/apps/presentationeditor/main/app/controller/Search.js +++ b/apps/presentationeditor/main/app/controller/Search.js @@ -272,7 +272,7 @@ define([ onApiGetTextAroundSearch: function (data) { if (this.view && this._state.isStartedAddingResults) { - if (data.length > 300) return; + if (data.length > 300 || !data.length) return; var me = this; me.resultItems = []; data.forEach(function (item, ind) { @@ -321,11 +321,12 @@ define([ viewport.searchBar.hide(); } - var text = findText || this.api.asc_GetSelectedText() || this._state.searchText; + var text = typeof findText === 'string' ? findText : (this.api.asc_GetSelectedText() || this._state.searchText); if (text) { this.view.setFindText(text); - } else if (text !== undefined) { + } else if (text !== undefined) { // panel was opened from empty searchbar, clear to start new search this.view.setFindText(''); + this._state.searchText = undefined; } this.hideResults(); diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 723ca475d..1d07b9d61 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -683,7 +683,7 @@ define([ if (this.isSearchPanelVisible()) { selectedText && this.leftMenu.panelSearch.setFindText(selectedText); this.leftMenu.panelSearch.focus(selectedText !== '' ? s : 'search'); - this.leftMenu.fireEvent('search:aftershow', this.leftMenu, selectedText); + this.leftMenu.fireEvent('search:aftershow', [selectedText]); return false; } else if (this.getApplication().getController('Viewport').isSearchBarVisible()) { var viewport = this.getApplication().getController('Viewport'); @@ -840,7 +840,7 @@ define([ if (state) { Common.UI.Menu.Manager.hideAll(); this.leftMenu.showMenu('advancedsearch'); - this.leftMenu.fireEvent('search:aftershow', this.leftMenu, findText); + this.leftMenu.fireEvent('search:aftershow', [findText]); } else { this.leftMenu.btnSearchBar.toggle(false, true); this.leftMenu.onBtnMenuClick(this.leftMenu.btnSearchBar); diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js index f0465d066..36ddf3c6f 100644 --- a/apps/spreadsheeteditor/main/app/controller/Search.js +++ b/apps/spreadsheeteditor/main/app/controller/Search.js @@ -413,7 +413,7 @@ define([ onApiGetTextAroundSearch: function (data) { // [id, sheet, name, cell, value, formula] if (this.view && this._state.isStartedAddingResults) { - if (data.length > 300) return; + if (data.length > 300 || !data.length) return; var me = this, $innerResults = me.view.$resultsContainer.find('.search-items'); me.resultItems = []; @@ -474,20 +474,21 @@ define([ viewport.searchBar.hide(); } - var text = findText || this.api.asc_GetSelectedText() || this._state.searchText; + var text = typeof findText === 'string' ? findText : (this.api.asc_GetSelectedText() || this._state.searchText); if (this.resultItems && this.resultItems.length > 0 && (!this._state.matchCase && text.toLowerCase() === this.view.inputText.getValue().toLowerCase() || this._state.matchCase && text === this.view.inputText.getValue())) { // show old results return; } - if (text && text !== this.view.inputText.getValue()) { + if (text) { this.view.setFindText(text); - } else if (text !== undefined) { + } else if (text !== undefined) { // panel was opened from empty searchbar, clear to start new search this.view.setFindText(''); + this._state.searchText = undefined; } this.hideResults(); - if (text !== '') { // search was made + if (text !== '' && text === this._state.searchText) { // search was made this.view.disableReplaceButtons(false); this.api.asc_StartTextAroundSearch(); } else if (text !== '') { // search wasn't made