From 35b20618559596be2464dac12b578e4ecbe58d72 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sat, 26 Sep 2020 16:58:37 +0300 Subject: [PATCH] [Commom] Add focus method for input field, combobos, spinner components. [SSE] Fix focus for data range fields --- apps/common/main/lib/component/ComboBox.js | 6 +++++- apps/common/main/lib/component/InputField.js | 2 +- apps/common/main/lib/component/MetricSpinner.js | 4 ++++ apps/spreadsheeteditor/main/app/controller/Print.js | 6 ++++++ .../main/app/view/ChartDataRangeDialog.js | 2 +- .../main/app/view/CreatePivotDialog.js | 13 ++++++++----- .../main/app/view/FormulaWizard.js | 4 ++-- .../main/app/view/NamedRangeEditDlg.js | 12 +++++++----- 8 files changed, 34 insertions(+), 15 deletions(-) diff --git a/apps/common/main/lib/component/ComboBox.js b/apps/common/main/lib/component/ComboBox.js index e11cef944..6bd870c28 100644 --- a/apps/common/main/lib/component/ComboBox.js +++ b/apps/common/main/lib/component/ComboBox.js @@ -343,7 +343,7 @@ define([ Common.NotificationCenter.trigger('menu:hide', this, isFromInputControl); if (this.options.takeFocusOnClose) { var me = this; - setTimeout(function(){me._input.focus();}, 1); + setTimeout(function(){me.focus();}, 1); } }, @@ -677,6 +677,10 @@ define([ wheelSpeed: 10, alwaysVisibleY: this.scrollAlwaysVisible }, this.options.scroller)); + }, + + focus: function() { + this._input && this._input.focus(); } } })()); diff --git a/apps/common/main/lib/component/InputField.js b/apps/common/main/lib/component/InputField.js index df8164441..72a29504c 100644 --- a/apps/common/main/lib/component/InputField.js +++ b/apps/common/main/lib/component/InputField.js @@ -300,7 +300,7 @@ define([ }, focus: function() { - this._input.focus(); + this._input && this._input.focus(); }, checkValidate: function() { diff --git a/apps/common/main/lib/component/MetricSpinner.js b/apps/common/main/lib/component/MetricSpinner.js index b90673569..f7c13b5f9 100644 --- a/apps/common/main/lib/component/MetricSpinner.js +++ b/apps/common/main/lib/component/MetricSpinner.js @@ -537,6 +537,10 @@ define([ v_out = parseFloat((v_out * 6.0 / 25.4).toFixed(6)); return v_out; + }, + + focus: function() { + if (this.$input) this.$input.focus(); } }); diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index a4ae6251e..db4168a58 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -521,6 +521,9 @@ define([ handler: handlerDlg }).on('close', function() { panel.show(); + _.delay(function(){ + txtRange.focus(); + },1); }); var xy = panel.$window.offset(); @@ -544,6 +547,9 @@ define([ panel.dataRangeTop = value; else panel.dataRangeLeft = value; + _.delay(function(){ + txtRange.focus(); + },1); } }, diff --git a/apps/spreadsheeteditor/main/app/view/ChartDataRangeDialog.js b/apps/spreadsheeteditor/main/app/view/ChartDataRangeDialog.js index f0d1736d2..c4a65ef18 100644 --- a/apps/spreadsheeteditor/main/app/view/ChartDataRangeDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ChartDataRangeDialog.js @@ -239,7 +239,7 @@ define([ me.show(); _.delay(function(){ me._noApply = true; - input.cmpEl.find('input').focus(); + input.focus(); me._noApply = false; },1); }); diff --git a/apps/spreadsheeteditor/main/app/view/CreatePivotDialog.js b/apps/spreadsheeteditor/main/app/view/CreatePivotDialog.js index 3420c8863..94d7bd99c 100644 --- a/apps/spreadsheeteditor/main/app/view/CreatePivotDialog.js +++ b/apps/spreadsheeteditor/main/app/view/CreatePivotDialog.js @@ -169,15 +169,15 @@ define([ afterRender: function() { this._setDefaults(this.props); + + var me = this; + _.delay(function(){ + me.txtSourceRange.focus(); + },50); }, show: function() { Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments); - - var me = this; - _.delay(function(){ - me.txtSourceRange.cmpEl.find('input').focus(); - },50); }, _setDefaults: function (props) { @@ -260,6 +260,9 @@ define([ handler: handlerDlg }).on('close', function() { me.show(); + _.delay(function(){ + txtRange.focus(); + },1); }); var xy = me.$window.offset(); diff --git a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js index fe22a0818..d69c34142 100644 --- a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js +++ b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js @@ -215,7 +215,7 @@ define([ _.delay(function(){ me._noApply = true; - me.args[0].argInput.cmpEl.find('input').focus(); + me.args[0].argInput.focus(); me._noApply = false; },100); } @@ -367,7 +367,7 @@ define([ me.show(); _.delay(function(){ me._noApply = true; - input.cmpEl.find('input').focus(); + input.focus(); me._noApply = false; },1); }); diff --git a/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js b/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js index f637376cd..6b8f371c9 100644 --- a/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js +++ b/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js @@ -184,15 +184,14 @@ define([ this.api.asc_registerCallback('asc_onLockDefNameManager', this.wrapEvents.onLockDefNameManager); this.api.asc_registerCallback('asc_onRefreshDefNameList', this.wrapEvents.onRefreshDefNameList); - }, - - show: function() { - Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments); var me = this; _.delay(function(){ me.inputName.cmpEl.find('input').focus(); - },200); + },200); }, + + show: function() { + Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments); }, _setDefaults: function (props) { @@ -231,6 +230,9 @@ define([ handler: handlerDlg }).on('close', function() { me.show(); + _.delay(function(){ + me.txtDataRange.focus(); + },1); }); var xy = me.$window.offset();