-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Adjust clashing shortcuts used for character input #14681
Conversation
This is great! It globally replaces Shift+Alt with Ctrl+Alt (on OSX). This is also the basic behaviour (Ctrl+Alt) that the HTML accesskey has: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey I tested and it worked as described, but I am not aware if this has other implications. |
It has already been pointed out that the "standard" WordPress Keyboard shortcuts that use the Help shortcut conflicts with VoiceOver Help shortcut (Mac) So this is a known issue, and I'm not sure why we'd want to keep using In #11154 I've also linked to a useful resource by the W3C: in the new WAI-ARIA Authoring Practices 1.1 there's a section dedicated to keyboard shortcuts. It's more about what not to do, see: https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_shortcuts_assigning There's a list of combinations to avoid and, among others, it's clearly stated to avoid:
Also:
This actually means all these shortcuts are not available to VoiceOver users so I'm afraid I can't support this change as it creates an accessibility barrier. |
@afercia I'm very well aware that Which VoiceOver commands will clash with these two? Other options:
|
@ellatrix thanks. Can you please clarify Anyways, here's a list of the VoiceOver commands, where
VO + Down and Up arrows are widely used for navigation and to change settings; |
@ellatrix This looks good. There's one extra place to update the documented shortcut: |
@afercia - I can help answer that. My understanding is that the two navigate regions shortcuts are the only ones bound in Gutenberg that are using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ellatrix there is this doc file that should be updated once the shortcuts are changed,
https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/faq.md#editor-shortcuts
Do you have the time to update it or may I edit your PR?
Otherwise with the follow-up confirmation from @talldan I think we're good to go!
@draganescu yep, I'm happy. It might be worth just pushing the changes to that file in a commit and then merging. I'm sure @ellatrix won't mind. |
2d1a65f
to
92aefd3
Compare
rebased, updated the docs and inlined the script based on @aduth suggestion |
Thanks for the updates @draganescu! |
* Adjust clashing shortcuts used for character input * Update modal * adds docs correction to correspond, adds inlined script to remove production dead code
* Adjust clashing shortcuts used for character input * Update modal * adds docs correction to correspond, adds inlined script to remove production dead code
* Adjust clashing shortcuts used for character input * Update modal * adds docs correction to correspond, adds inlined script to remove production dead code
forEach( this.props.shortcuts, ( callback, key ) => { | ||
if ( process.env.NODE_ENV === 'development' ) { | ||
const keys = key.split( '+' ); | ||
const modifiers = new Set( keys.filter( ( value ) => value.length > 1 ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this capture much more than just modifiers, like escape
, or space
, or tab
? While ultimately it has no impact one way or the other since the subsequent lines only care to check for alt
or shift
specifically, it begs the question at that point why to filter at all (vs. hasAlt = keys.includes( 'alt' )
).
( modifiers.size === 1 && hasAlt ) || | ||
( modifiers.size === 2 && hasAlt && hasShift ) | ||
) { | ||
throw new Error( `Cannot bind ${ key }. Alt and Shift+Alt modifiers are reserved for character input.` ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's expected this should crash the application (to make the problem exceedingly obvious)? As there's been some prior conversation at #13405 and alternative approaches at #14151 to address these sorts of "wrong usage" violations, it seems we might consider having a unified approach to when and how they should be introduced. Personally I'd favor ESLint rules since they can be captured at build-time than at runtime, but I could grant that (a) there's more effort involved in creating the rules (though not always) and (b) this assumes that the developer has opted into using ESLint and the custom rules, which is not a given.
Description
Fixes #13118. Replaces the
shift+alt
combination with the "standard" WordPressaccess
combination.Also adds a check to
KeyboardShortcuts
to prevent this mistake from happening in the future.How has this been tested?
Screenshots
Types of changes
Checklist: