Skip to content

Commit

Permalink
Oh hey metaKey is its own special thing
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Jun 18, 2024
1 parent 7f5f493 commit 71ca80e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/23365.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Dont show keyboard nav hints when taking a screenshot
```
7 changes: 2 additions & 5 deletions ui/app/services/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,8 @@ export default class KeyboardService extends Service {
const shifted = event.getModifierState('Shift');
if (type === 'press') {
if (key === 'Shift') {
// if cmd or ctrl are pressed, don't show hints — this is likely a user trying to take a screenshot.
if (
event.getModifierState('Meta') ||
event.getModifierState('Control')
) {
// if cmd/windows key is pressed, don't show hints — this is likely a user trying to take a screenshot.
if (event.getModifierState('Meta')) {
return;
}
this.displayHints = true;
Expand Down
6 changes: 4 additions & 2 deletions ui/tests/acceptance/keyboard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,10 @@ module('Acceptance | keyboard', function (hooks) {
'Hints disappear when you release Shift'
);

triggerEvent('.page-layout', 'keydown', { key: 'Meta' });
await triggerEvent('.page-layout', 'keydown', { key: 'Shift' });
await triggerEvent('.page-layout', 'keydown', {
key: 'Shift',
metaKey: true,
});
assert.equal(
document.querySelectorAll('[data-test-keyboard-hint]').length,
0,
Expand Down

0 comments on commit 71ca80e

Please sign in to comment.