Skip to content

Commit

Permalink
Fixed global-search keyboard shortcut for non-english keyboard layouts.
Browse files Browse the repository at this point in the history
Closes #10646
  • Loading branch information
apollo13 authored and Mahmood Ali committed Jun 9, 2021
1 parent 5c265fb commit 114dc1a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ui/app/components/global-search/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { debounce, run } from '@ember/runloop';
import Searchable from 'nomad-ui/mixins/searchable';
import classic from 'ember-classic-decorator';

const SLASH_KEY = 191;
const SLASH_KEY = '/';
const MAXIMUM_RESULTS = 10;

@classNames('global-search-container')
Expand Down Expand Up @@ -39,7 +39,7 @@ export default class GlobalSearchControl extends Component {
const targetElementName = e.target.nodeName.toLowerCase();

if (targetElementName != 'input' && targetElementName != 'textarea') {
if (e.keyCode === SLASH_KEY) {
if (e.key === SLASH_KEY) {
e.preventDefault();
this.open();
}
Expand Down
6 changes: 2 additions & 4 deletions ui/tests/acceptance/search-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ module('Acceptance | search', function(hooks) {

assert.notOk(Layout.navbar.search.field.isPresent);

await triggerEvent('.page-layout', 'keydown', {
keyCode: 191, // slash
});
await triggerEvent('.page-layout', 'keydown', { key: '/' });

assert.ok(Layout.navbar.search.field.isPresent);
});
Expand All @@ -213,7 +211,7 @@ module('Acceptance | search', function(hooks) {
assert.notOk(Layout.navbar.search.field.isPresent);

await JobsList.search.click();
await JobsList.search.keydown({ keyCode: 191 });
await JobsList.search.keydown({ key: '/' });

assert.notOk(Layout.navbar.search.field.isPresent);
});
Expand Down

0 comments on commit 114dc1a

Please sign in to comment.