From 477c0431ddb65afeec6c6596d0544e1e9a9c9da0 Mon Sep 17 00:00:00 2001
From: JuliaSvinareva <Julia.Svinaryova@onlyoffice.com>
Date: Tue, 12 Jul 2022 15:55:52 +0300
Subject: [PATCH 1/7] [forms] Fix icon color in dark mode

---
 apps/common/forms/resources/less/common.less | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/apps/common/forms/resources/less/common.less b/apps/common/forms/resources/less/common.less
index f303d3142..17545a3e6 100644
--- a/apps/common/forms/resources/less/common.less
+++ b/apps/common/forms/resources/less/common.less
@@ -546,15 +546,15 @@
     }
     &.search-close {
         background-position: -@icon-width*18 0;
-    }
-    &.search {
-        background-position: -@icon-width*24 0;
+        background-position: -@icon-width*18 @icon-normal-top;
     }
     &.search-arrow-up {
         background-position: -@icon-width*27 0;
+        background-position: -@icon-width*27 @icon-normal-top;
     }
     &.search-arrow-down {
         background-position: -@icon-width*28 0;
+        background-position: -@icon-width*28 @icon-normal-top;
     }
 }
 

From 097e2276cb99a08de0b204c65ffa5b1b255115a8 Mon Sep 17 00:00:00 2001
From: JuliaSvinareva <Julia.Svinaryova@onlyoffice.com>
Date: Tue, 12 Jul 2022 16:00:10 +0300
Subject: [PATCH 2/7] [forms] Fix error when menu item was clicked

---
 apps/common/main/lib/component/MenuItem.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apps/common/main/lib/component/MenuItem.js b/apps/common/main/lib/component/MenuItem.js
index ab5fc79d8..373ca9d99 100644
--- a/apps/common/main/lib/component/MenuItem.js
+++ b/apps/common/main/lib/component/MenuItem.js
@@ -301,7 +301,7 @@ define([
         },
 
         onItemMouseDown: function(e) {
-            Common.UI.HintManager.clearHints();
+            Common.UI.HintManager && Common.UI.HintManager.clearHints();
             if (e.which != 1) {
                 e.preventDefault();
                 e.stopPropagation();

From a2fb77792dbbb63c308edc7e9a38cc3084a88eaf Mon Sep 17 00:00:00 2001
From: JuliaSvinareva <Julia.Svinaryova@onlyoffice.com>
Date: Tue, 12 Jul 2022 16:12:51 +0300
Subject: [PATCH 3/7] [SSE] Bug 58086

---
 apps/spreadsheeteditor/main/app/controller/Search.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js
index 6680e7488..9ae4de9f0 100644
--- a/apps/spreadsheeteditor/main/app/controller/Search.js
+++ b/apps/spreadsheeteditor/main/app/controller/Search.js
@@ -196,7 +196,7 @@ define([
 
         onSearchNext: function (type, text, e) {
             var isReturnKey = type === 'keydown' && e.keyCode === Common.UI.Keys.RETURN;
-            if (text && text.length > 0 && (isReturnKey || type !== 'keydown')) {
+            if (isReturnKey || type !== 'keydown') {
                 this._state.searchText = text;
                 if (this.onQuerySearch(type) && (this.searchTimer || isReturnKey)) {
                     this.hideResults();
@@ -222,7 +222,7 @@ define([
 
                         me.hideResults();
                         me._state.searchText = me._state.newSearchText;
-                        if (me._state.newSearchText !== '' && me.onQuerySearch()) {
+                        if (me.onQuerySearch()) {
                             if (me.view.$el.is(':visible')) {
                                 me.api.asc_StartTextAroundSearch();
                             }

From a3ce08a60213d9acd79ddccc41ca82a1c965abcc Mon Sep 17 00:00:00 2001
From: JuliaSvinareva <Julia.Svinaryova@onlyoffice.com>
Date: Tue, 12 Jul 2022 16:42:56 +0300
Subject: [PATCH 4/7] [SSE] Bug 58086

---
 apps/spreadsheeteditor/main/app/controller/Search.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js
index 9ae4de9f0..0355493be 100644
--- a/apps/spreadsheeteditor/main/app/controller/Search.js
+++ b/apps/spreadsheeteditor/main/app/controller/Search.js
@@ -158,7 +158,7 @@ define([
                     this._state.lookInFormulas = value;
                     break;
             }
-            if (runSearch && this._state.searchText) {
+            if (runSearch) {
                 this.hideResults();
                 if (this.onQuerySearch()) {
                     this.searchTimer && clearInterval(this.searchTimer);

From 8fd396814c94d6d07fe60c8edfc6eb8b121aa99b Mon Sep 17 00:00:00 2001
From: JuliaSvinareva <Julia.Svinaryova@onlyoffice.com>
Date: Wed, 13 Jul 2022 16:33:36 +0300
Subject: [PATCH 5/7] [SSE] Fix disabling of nav buttons in search panel

---
 apps/common/main/lib/view/SearchBar.js         |  2 +-
 apps/common/main/lib/view/SearchPanel.js       |  2 +-
 .../main/app/controller/Search.js              | 18 ++++++++----------
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/apps/common/main/lib/view/SearchBar.js b/apps/common/main/lib/view/SearchBar.js
index ac98141a4..fbd279570 100644
--- a/apps/common/main/lib/view/SearchBar.js
+++ b/apps/common/main/lib/view/SearchBar.js
@@ -185,7 +185,7 @@ define([
         },
 
         disableNavButtons: function (resultNumber, allResults) {
-            var disable = this.inputSearch.val() === '' || !allResults;
+            var disable = (this.inputSearch.val() === '' && !window.SSE) || !allResults;
             this.btnBack.setDisabled(disable);
             this.btnNext.setDisabled(disable);
         },
diff --git a/apps/common/main/lib/view/SearchPanel.js b/apps/common/main/lib/view/SearchPanel.js
index 6ac4bb164..a9836fa94 100644
--- a/apps/common/main/lib/view/SearchPanel.js
+++ b/apps/common/main/lib/view/SearchPanel.js
@@ -375,7 +375,7 @@ define([
         },
 
         disableNavButtons: function (resultNumber, allResults) {
-            var disable = this.inputText._input.val() === '' || !allResults;
+            var disable = (this.inputText._input.val() === '' && !window.SSE) || !allResults;
             this.btnBack.setDisabled(disable);
             this.btnNext.setDisabled(disable);
         },
diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js
index 0355493be..05b578658 100644
--- a/apps/spreadsheeteditor/main/app/controller/Search.js
+++ b/apps/spreadsheeteditor/main/app/controller/Search.js
@@ -80,7 +80,7 @@ define([
         },
         onLaunch: function () {
             this._state = {
-                searchText: '',
+                searchText: undefined,
                 matchCase: false,
                 matchWord: false,
                 useRegExp: false,
@@ -226,11 +226,10 @@ define([
                             if (me.view.$el.is(':visible')) {
                                 me.api.asc_StartTextAroundSearch();
                             }
-                            //me.view.disableReplaceButtons(false);
                         } else if (me._state.newSearchText === '') {
                             me.view.updateResultsNumber('no-results');
                             me.view.disableNavButtons();
-                            //me.view.disableReplaceButtons(true);
+                            Common.NotificationCenter.trigger('search:updateresults', undefined, 0);
                         }
                         clearInterval(me.searchTimer);
                         me.searchTimer = undefined;
@@ -267,10 +266,10 @@ define([
             if (!this.api.asc_findText(options)) {
                 this.resultItems = [];
                 this.view.updateResultsNumber(undefined, 0);
-                //this.view.disableReplaceButtons(true);
                 this._state.currentResult = 0;
                 this._state.resultsNumber = 0;
                 this.view.disableNavButtons();
+                Common.NotificationCenter.trigger('search:updateresults', undefined, 0);
                 return false;
             }
             return true;
@@ -348,10 +347,10 @@ define([
             this.resultItems = [];
             this.hideResults();
             this.view.updateResultsNumber(type, 0); // type === undefined, count === 0 -> no matches
-            //this.view.disableReplaceButtons(true);
             this._state.currentResult = 0;
             this._state.resultsNumber = 0;
             this.view.disableNavButtons();
+            Common.NotificationCenter.trigger('search:updateresults', undefined, 0);
         },
 
         onApiRemoveTextAroundSearch: function (arr) {
@@ -482,7 +481,8 @@ define([
 
             var text = typeof findText === 'string' ? findText : (this.api.asc_GetSelectedText() || this._state.searchText);
             if (this.resultItems && this.resultItems.length > 0 &&
-                (!this._state.matchCase && text && text.toLowerCase() === this.view.inputText.getValue().toLowerCase() ||
+                    (!text && !this.view.inputText.getValue() ||
+                    !this._state.matchCase && text && text.toLowerCase() === this.view.inputText.getValue().toLowerCase() ||
                     this._state.matchCase && text === this.view.inputText.getValue())) { // show old results
                 return;
             }
@@ -494,14 +494,12 @@ define([
             }
 
             this.hideResults();
-            if (text && text !== '' && text === this._state.searchText) { // search was made
-                //this.view.disableReplaceButtons(false);
+            if (this._state.searchText !== undefined && text === this._state.searchText) { // search was made
                 this.api.asc_StartTextAroundSearch();
-            } else if (text && text !== '') { // search wasn't made
+            } else if (this._state.searchText !== undefined) { // search wasn't made
                 this.onInputSearchChange(text);
             } else {
                 this.resultItems = [];
-                //this.view.disableReplaceButtons(true);
                 this.view.clearResultsNumber();
             }
             this.view.disableNavButtons(this._state.currentResult, this._state.resultsNumber);

From e7548750817bc371b536b35f982a571de075b43c Mon Sep 17 00:00:00 2001
From: JuliaSvinareva <Julia.Svinaryova@onlyoffice.com>
Date: Wed, 13 Jul 2022 17:23:03 +0300
Subject: [PATCH 6/7] [SSE] Bug 58085

---
 apps/spreadsheeteditor/main/app/controller/Search.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js
index 05b578658..76a792606 100644
--- a/apps/spreadsheeteditor/main/app/controller/Search.js
+++ b/apps/spreadsheeteditor/main/app/controller/Search.js
@@ -106,6 +106,7 @@ define([
                 this.api.asc_registerCallback('asc_onGetTextAroundSearchPack', _.bind(this.onApiGetTextAroundSearch, this));
                 this.api.asc_registerCallback('asc_onRemoveTextAroundSearch', _.bind(this.onApiRemoveTextAroundSearch, this));
                 this.api.asc_registerCallback('asc_onSearchEnd', _.bind(this.onApiSearchEnd, this));
+                this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onActiveSheetChanged, this));
             }
             return this;
         },
@@ -545,6 +546,17 @@ define([
             this.removeResultItems('stop');
         },
 
+        onActiveSheetChanged: function (index) {
+            if (this._state.isHighlightedResults && this._state.withinSheet === Asc.c_oAscSearchBy.Sheet) {
+                this.hideResults();
+                if (this.onQuerySearch()) {
+                    this.searchTimer && clearInterval(this.searchTimer);
+                    this.searchTimer = undefined;
+                    this.api.asc_StartTextAroundSearch();
+                }
+            }
+        },
+
         textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.',
         textReplaceSuccess: 'Search has been done. {0} occurrences have been replaced',
         textReplaceSkipped: 'The replacement has been made. {0} occurrences were skipped.',

From 22ef02834b357c874e28bd4db24b7320b688f13d Mon Sep 17 00:00:00 2001
From: JuliaSvinareva <Julia.Svinaryova@onlyoffice.com>
Date: Thu, 14 Jul 2022 11:34:46 +0300
Subject: [PATCH 7/7] [SSE] Fix bug 58085

---
 apps/spreadsheeteditor/main/app/controller/Search.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js
index 76a792606..9bde72fd4 100644
--- a/apps/spreadsheeteditor/main/app/controller/Search.js
+++ b/apps/spreadsheeteditor/main/app/controller/Search.js
@@ -239,7 +239,7 @@ define([
             }
         },
 
-        onQuerySearch: function (d, w, opts, fromPanel) {
+        onQuerySearch: function (d, isNeedRecalc) {
             var me = this;
             if (this._state.withinSheet === Asc.c_oAscSearchBy.Range && !this._state.isValidSelectedRange) {
                 Common.UI.warning({
@@ -264,6 +264,7 @@ define([
             }
             options.asc_setScanByRows(this._state.searchByRows);
             options.asc_setLookIn(this._state.lookInFormulas ? Asc.c_oAscFindLookIn.Formulas : Asc.c_oAscFindLookIn.Value);
+            options.asc_setNeedRecalc(isNeedRecalc);
             if (!this.api.asc_findText(options)) {
                 this.resultItems = [];
                 this.view.updateResultsNumber(undefined, 0);
@@ -549,7 +550,7 @@ define([
         onActiveSheetChanged: function (index) {
             if (this._state.isHighlightedResults && this._state.withinSheet === Asc.c_oAscSearchBy.Sheet) {
                 this.hideResults();
-                if (this.onQuerySearch()) {
+                if (this.onQuerySearch(undefined, true)) {
                     this.searchTimer && clearInterval(this.searchTimer);
                     this.searchTimer = undefined;
                     this.api.asc_StartTextAroundSearch();