From e27d11189e74dfc4a5c9830e2d74602ab6fea07e Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 21 Jul 2022 20:44:48 +0300 Subject: [PATCH] [DE PE SSE] Fix ability to navigate through search results by enter key --- apps/common/main/lib/view/SearchBar.js | 6 ++++-- apps/common/main/lib/view/SearchPanel.js | 6 ++++-- apps/documenteditor/main/app/controller/Search.js | 12 +++++++++--- .../presentationeditor/main/app/controller/Search.js | 12 +++++++++--- apps/spreadsheeteditor/main/app/controller/Search.js | 12 +++++++++--- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/apps/common/main/lib/view/SearchBar.js b/apps/common/main/lib/view/SearchBar.js index 4fb15b778..6631c1d74 100644 --- a/apps/common/main/lib/view/SearchBar.js +++ b/apps/common/main/lib/view/SearchBar.js @@ -198,13 +198,15 @@ define([ var elFocus = this.getChild().find(':focus'), action = elFocus.prop('id') === 'search-bar-next' ? 'next' : 'back'; elFocus.find('button')[e.keyCode === Common.UI.Keys.RETURN ? 'addClass' : 'removeClass']('focused'); - this.fireEvent('search:keydown-next', [action, this.inputSearch.val(), e]); - if (e.keyCode !== Common.UI.Keys.RETURN) { + if (e.keyCode === Common.UI.Keys.RETURN) { + this.fireEvent('search:keydown-next', [action, this.inputSearch.val(), e]); + } else { this.onMousedown(); } }, onMousedown: function () { + this.fireEvent('search:enable-key'); this.getChild().find('.focused').removeClass('focused'); $(document).off('keydown', this.wrapEvents.keydown); $(document).off('mousedown', this.wrapEvents.mousedown); diff --git a/apps/common/main/lib/view/SearchPanel.js b/apps/common/main/lib/view/SearchPanel.js index f69ad7957..9f7be39d3 100644 --- a/apps/common/main/lib/view/SearchPanel.js +++ b/apps/common/main/lib/view/SearchPanel.js @@ -369,13 +369,15 @@ define([ var elFocus = $(':focus'), action = elFocus.prop('id') === 'search-adv-next' ? 'next' : 'back'; elFocus.find('button')[e.keyCode === Common.UI.Keys.RETURN ? 'addClass' : 'removeClass']('focused'); - this.fireEvent('search:keydown-next', [action, this.inputText.getValue(), e]); - if (e.keyCode !== Common.UI.Keys.RETURN) { + if (e.keyCode === Common.UI.Keys.RETURN) { + this.fireEvent('search:keydown-next', [action, this.inputText.getValue(), e]); + } else { this.onMousedown(); } }, onMousedown: function () { + this.fireEvent('search:enable-key'); this.$el.find('.focused').removeClass('focused'); $(document).off('keydown', this.wrapEvents.keydown); $(document).off('mousedown', this.wrapEvents.mousedown); diff --git a/apps/documenteditor/main/app/controller/Search.js b/apps/documenteditor/main/app/controller/Search.js index dd6912fa3..20b886568 100644 --- a/apps/documenteditor/main/app/controller/Search.js +++ b/apps/documenteditor/main/app/controller/Search.js @@ -67,7 +67,8 @@ define([ 'search:keydown': _.bind(this.onSearchNext, this, 'keydown'), 'show': _.bind(this.onSelectSearchingResults, this, true), 'hide': _.bind(this.onSelectSearchingResults, this, false), - 'search:keydown-next': _.bind(this.onKeydownNext, this) + 'search:keydown-next': _.bind(this.onKeydownNext, this), + 'search:enable-key': _.bind(this.enableKeyEvents, this) }, 'Common.Views.SearchPanel': { 'search:back': _.bind(this.onSearchNext, this, 'back'), @@ -79,7 +80,8 @@ define([ 'search:keydown': _.bind(this.onSearchNext, this, 'keydown'), 'show': _.bind(this.onShowPanel, this), 'hide': _.bind(this.onHidePanel, this), - 'search:keydown-next': _.bind(this.onKeydownNext, this) + 'search:keydown-next': _.bind(this.onKeydownNext, this), + 'search:enable-key': _.bind(this.enableKeyEvents, this) }, 'LeftMenu': { 'search:aftershow': _.bind(this.onShowAfterSearch, this) @@ -164,7 +166,11 @@ define([ }, onKeydownNext: function (type, text, e) { - e.keyCode === Common.UI.Keys.RETURN ? this.onSearchNext(type, text, e) : this.api.asc_enableKeyEvents(true); + this.onSearchNext(type, text, e); + }, + + enableKeyEvents: function () { + this.api.asc_enableKeyEvents(true); }, onInputSearchChange: function (text) { diff --git a/apps/presentationeditor/main/app/controller/Search.js b/apps/presentationeditor/main/app/controller/Search.js index a1b85917a..00c23d78b 100644 --- a/apps/presentationeditor/main/app/controller/Search.js +++ b/apps/presentationeditor/main/app/controller/Search.js @@ -65,7 +65,8 @@ define([ this.onInputSearchChange(text); }, this), 'search:keydown': _.bind(this.onSearchNext, this, 'keydown'), - 'search:keydown-next': _.bind(this.onKeydownNext, this) + 'search:keydown-next': _.bind(this.onKeydownNext, this), + 'search:enable-key': _.bind(this.enableKeyEvents, this) }, 'Common.Views.SearchPanel': { 'search:back': _.bind(this.onSearchNext, this, 'back'), @@ -77,7 +78,8 @@ define([ 'search:keydown': _.bind(this.onSearchNext, this, 'keydown'), 'show': _.bind(this.onShowPanel, this), 'hide': _.bind(this.onHidePanel, this), - 'search:keydown-next': _.bind(this.onKeydownNext, this) + 'search:keydown-next': _.bind(this.onKeydownNext, this), + 'search:enable-key': _.bind(this.enableKeyEvents, this) }, 'LeftMenu': { 'search:aftershow': _.bind(this.onShowAfterSearch, this) @@ -161,7 +163,11 @@ define([ }, onKeydownNext: function (type, text, e) { - e.keyCode === Common.UI.Keys.RETURN ? this.onSearchNext(type, text, e) : this.api.asc_enableKeyEvents(true); + this.onSearchNext(type, text, e); + }, + + enableKeyEvents: function () { + this.api.asc_enableKeyEvents(true); }, onInputSearchChange: function (text) { diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js index 92eaa842d..3221b758a 100644 --- a/apps/spreadsheeteditor/main/app/controller/Search.js +++ b/apps/spreadsheeteditor/main/app/controller/Search.js @@ -61,7 +61,8 @@ define([ 'search:keydown': _.bind(this.onSearchNext, this, 'keydown'), 'show': _.bind(this.onSelectSearchingResults, this, true), 'hide': _.bind(this.onSelectSearchingResults, this, false), - 'search:keydown-next': _.bind(this.onKeydownNext, this) + 'search:keydown-next': _.bind(this.onKeydownNext, this), + 'search:enable-key': _.bind(this.enableKeyEvents, this) }, 'Common.Views.SearchPanel': { 'search:back': _.bind(this.onSearchNext, this, 'back'), @@ -73,7 +74,8 @@ define([ 'search:keydown': _.bind(this.onSearchNext, this, 'keydown'), 'show': _.bind(this.onShowPanel, this), 'hide': _.bind(this.onHidePanel, this), - 'search:keydown-next': _.bind(this.onKeydownNext, this) + 'search:keydown-next': _.bind(this.onKeydownNext, this), + 'search:enable-key': _.bind(this.enableKeyEvents, this) }, 'LeftMenu': { // TO DO 'search:aftershow': _.bind(this.onShowAfterSearch, this) @@ -218,7 +220,11 @@ define([ }, onKeydownNext: function (type, text, e) { - e.keyCode === Common.UI.Keys.RETURN ? this.onSearchNext(type, text, e) : this.api.asc_enableKeyEvents(true); + this.onSearchNext(type, text, e); + }, + + enableKeyEvents: function () { + this.api.asc_enableKeyEvents(true); }, onInputSearchChange: function (text) {