focus search field on Ctrl-F in manager (#935)

This commit is contained in:
tophf 2020-05-23 06:12:54 +03:00 committed by GitHub
parent 367d1672c5
commit 379c825408
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,18 +73,22 @@ onDOMready().then(() => {
}
function maybeRefocus(event) {
if (event.altKey || event.ctrlKey || event.metaKey ||
event.target.matches('[type="text"], [type="search"], [type="number"]') ||
$('#message-box')) {
if (event.altKey || event.metaKey || $('#message-box')) {
return;
}
const inTextInput = event.target.matches('[type=text], [type=search], [type=number]');
const {which: k, key} = event;
// focus search field on "/" key
if (key === '/' || !key && k === 191 && !event.shiftKey) {
// focus search field on "/" or Ctrl-F key
if (event.ctrlKey
? (event.code === 'KeyF' || !event.code && k === 70) && !event.shiftKey
: (key === '/' || !key && k === 191 && !event.shiftKey) && !inTextInput) {
event.preventDefault();
$('#search').focus();
return;
}
if (event.ctrlKey || inTextInput) {
return;
}
const time = performance.now();
if (
// 0-9