Skip to content

Commit 73106d4

Browse files
committed
Focus search field when pressing '/'
1 parent 42e615f commit 73106d4

File tree

1 file changed

+19
-0
lines changed
  • app/design/adminhtml/Magento/backend/web/js

1 file changed

+19
-0
lines changed

app/design/adminhtml/Magento/backend/web/js/theme.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,25 @@ define('globalSearch', [
345345
this.input.on('focus.activateGlobalSearchForm', function () {
346346
self.field.addClass(self.options.fieldActiveClass);
347347
});
348+
349+
$(document).keydown(function (e) {
350+
var inputs = [
351+
'input',
352+
'select',
353+
'textarea'
354+
];
355+
356+
if (e.which !== 191 || // forward slash - '/'
357+
inputs.indexOf(e.target.tagName.toLowerCase()) !== -1 ||
358+
e.target.isContentEditable
359+
) {
360+
return;
361+
}
362+
363+
e.preventDefault();
364+
365+
self.input.focus();
366+
});
348367
}
349368
});
350369

0 commit comments

Comments
 (0)