Merge pull request #529 from ONLYOFFICE/feature/pr-focus-manager

Feature/pr focus manager
This commit is contained in:
Julia Radzhabova 2020-10-21 11:18:36 +03:00 committed by GitHub
commit 1478a3b4aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 9 deletions

View file

@ -149,6 +149,11 @@ Common.UI.FocusManager = new(function() {
_windows[e.cid].fields = register(e.getFocusedComponents()); _windows[e.cid].fields = register(e.getFocusedComponents());
addTraps(_windows[e.cid]); addTraps(_windows[e.cid]);
} }
if (e && e.getDefaultFocusableComponent())
setTimeout(function(){
e.getDefaultFocusableComponent().focus();
}, 100);
}, },
'modal:close': function(e, last) { 'modal:close': function(e, last) {
if (e && e.cid && _windows[e.cid]) { if (e && e.cid && _windows[e.cid]) {

View file

@ -984,6 +984,10 @@ define([
return []; return [];
}, },
getDefaultFocusableComponent: function() {
return undefined;
},
cancelButtonText: 'Cancel', cancelButtonText: 'Cancel',
okButtonText: 'OK', okButtonText: 'OK',
yesButtonText: 'Yes', yesButtonText: 'Yes',

View file

@ -128,16 +128,16 @@ define([
this.getChild().find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); this.getChild().find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.updateMetricUnit(); this.updateMetricUnit();
setTimeout(function(){
me.spnColumns.focus();
}, 100);
}, },
getFocusedComponents: function() { getFocusedComponents: function() {
return [this.spnColumns, this.spnSpacing]; return [this.spnColumns, this.spnSpacing];
}, },
getDefaultFocusableComponent: function () {
return this.spnColumns;
},
_handleInput: function(state) { _handleInput: function(state) {
if (this.options.handler) { if (this.options.handler) {
this.options.handler.call(this, this, state); this.options.handler.call(this, this, state);

View file

@ -341,6 +341,10 @@ define([
return [this.cmbFormat, this.cmbAlign, this.cmbSize, {cmp: this.levelsList, selector: '.listview'}]; return [this.cmbFormat, this.cmbAlign, this.cmbSize, {cmp: this.levelsList, selector: '.listview'}];
}, },
getDefaultFocusableComponent: function () {
return this.type > 0 ? this.cmbFormat : this.cmbAlign;
},
afterRender: function() { afterRender: function() {
this.updateThemeColors(); this.updateThemeColors();
this._setDefaults(this.props); this._setDefaults(this.props);
@ -356,11 +360,6 @@ define([
show: function() { show: function() {
Common.UI.Window.prototype.show.apply(this, arguments); Common.UI.Window.prototype.show.apply(this, arguments);
var me = this;
_.delay(function(){
(me.type>0) ? me.cmbFormat.focus() : me.cmbAlign.focus();
},100);
}, },
updateThemeColors: function() { updateThemeColors: function() {