Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] Dont show keyboard hints when a user is trying to take a screenshot #23365

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ui/app/services/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,13 @@ 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')
philrenaud marked this conversation as resolved.
Show resolved Hide resolved
) {
return;
}
this.displayHints = true;
} else {
if (!DISALLOWED_KEYS.includes(key)) {
Expand Down
10 changes: 10 additions & 0 deletions ui/tests/acceptance/keyboard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ module('Acceptance | keyboard', function (hooks) {
0,
'Hints disappear when you release Shift'
);

triggerEvent('.page-layout', 'keydown', { key: 'Meta' });
await triggerEvent('.page-layout', 'keydown', { key: 'Shift' });
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
Loading