Skip to content

Commit

Permalink
[ui] Dont show keyboard hints when a user is trying to take a screens…
Browse files Browse the repository at this point in the history
…hot (#23365)

* Dont show keyboard hints when a user is trying to take a screenshot

* Oh hey metaKey is its own special thing
  • Loading branch information
philrenaud authored Jun 18, 2024
1 parent 54115a1 commit 5aad029
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 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
```
4 changes: 4 additions & 0 deletions ui/app/services/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ export default class KeyboardService extends Service {
const shifted = event.getModifierState('Shift');
if (type === 'press') {
if (key === 'Shift') {
// 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;
} else {
if (!DISALLOWED_KEYS.includes(key)) {
Expand Down
12 changes: 12 additions & 0 deletions ui/tests/acceptance/keyboard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,18 @@ module('Acceptance | keyboard', function (hooks) {
0,
'Hints disappear when you release Shift'
);

await triggerEvent('.page-layout', 'keydown', {
key: 'Shift',
metaKey: true,
});
assert.equal(
document.querySelectorAll('[data-test-keyboard-hint]').length,
0,
'Hints do not show up when holding down Command+Shift'
);
await triggerEvent('.page-layout', 'keyup', { key: 'Shift' });
await triggerEvent('.page-layout', 'keyup', { key: 'Meta' });
});
});

Expand Down

0 comments on commit 5aad029

Please sign in to comment.