focus on searcn bar shortcut

This commit is contained in:
Yuri Kuznetsov
2022-08-02 18:35:14 +03:00
parent 6a5f15bbc5
commit 429faf405c
2 changed files with 54 additions and 2 deletions
+24
View File
@@ -162,6 +162,9 @@ function (Dep, /** typeof module:search-manager.Class */SearchManager) {
'Control+Space': function (e) {
this.handleShortcutKeyCtrlSpace(e);
},
'Control+Slash': function (e) {
this.handleShortcutKeyCtrlSlash(e);
},
},
/**
@@ -767,5 +770,26 @@ function (Dep, /** typeof module:search-manager.Class */SearchManager) {
this.actionCreate({focusForCreate: true});
},
/**
* @protected
* @param {JQueryKeyEventObject} e
*/
handleShortcutKeyCtrlSlash: function (e) {
if (!this.searchPanel) {
return;
}
let $search = this.$el.find('input.text-filter').first();
if (!$search.length) {
return;
}
e.preventDefault();
e.stopPropagation();
$search.focus();
},
});
});
+30 -2
View File
@@ -56,6 +56,15 @@ define('views/modals/select-records', ['views/modal', 'search-manager'], functio
className: 'dialog dialog-record',
/**
* @inheritDoc
*/
shortcutKeys: {
'Control+Slash': function (e) {
this.handleShortcutKeyCtrlSlash(e);
},
},
data: function () {
return {
createButton: this.createButton,
@@ -171,9 +180,7 @@ define('views/modals/select-records', ['views/modal', 'search-manager'], functio
}
this.loadSearch();
this.wait(true);
this.loadList();
});
},
@@ -334,5 +341,26 @@ define('views/modals/select-records', ['views/modal', 'search-manager'], functio
});
});
},
/**
* @protected
* @param {JQueryKeyEventObject} e
*/
handleShortcutKeyCtrlSlash: function (e) {
if (!this.searchPanel) {
return;
}
let $search = this.$el.find('input.text-filter').first();
if (!$search.length) {
return;
}
e.preventDefault();
e.stopPropagation();
$search.focus();
},
});
});