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

Add new keyboard shortcuts help modal #8316

Merged
merged 40 commits into from
Aug 10, 2018
Merged

Conversation

talldan
Copy link
Contributor

@talldan talldan commented Jul 31, 2018

Description

Related issues - #71, #2980, #5420

Pressing ctl+option+h (shift+alt+h on windows/linux) displays a modal detailing keyboard shortcuts.

How has this been tested?

  • Manual testing (both Mac & Windows)
    • Test opening/closing modal using keyboard (esc also closes, as does hitting enter while the close
      button is focused)
    • Test opening/closing modal using mouse (open from more menu, close using button or clicking surrounding space)
    • Test classic block (that TinyMCE shortcut help doesn't also open at the same time as gutenberg shortcut help)
  • Snapshot tests
  • Added an e2e test that opens and closes modal using mouse and keyboard

Screenshots

screen shot 2018-08-09 at 4 14 10 pm

Types of changes

New feature (non-breaking change which adds functionality)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@talldan talldan requested a review from jasmussen July 31, 2018 08:41
@talldan talldan self-assigned this Jul 31, 2018
@talldan talldan added [Type] Enhancement A suggestion for improvement. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Status] In Progress Tracking issues with work in progress Needs Design Feedback Needs general design feedback. Needs Copy Review Needs review of user-facing copy (language, phrasing) labels Jul 31, 2018
@talldan
Copy link
Contributor Author

talldan commented Jul 31, 2018

Hey @jasmussen - before I take this one any further I thought I'd seek some design / copy feedback.

This has the same issue as the other PR with the formatting of shortcuts (e.g. ⌘+? instead of ⌘?), so I'll work on that now and cherry-pick the change onto both branches. (edit: updated screenshot with improvements)

Not sure if this is too wordy, or perhaps it should just be stripped back to something simpler. Any other design hints would be good. I know heading sizes are not quite right, should the modal have a bigger header?

@talldan talldan changed the title Add/keyboard shortcut modal Add new keyboard shortcuts help modal Jul 31, 2018
@jasmussen
Copy link
Contributor

Very very cool work, thank you for working on this.

I can't get the modal to show. meta+? isn't working for me. Also, can we make it Shift+? instead? This keyboard shortcut is standard in Google properties and others, might as well reuse existing patterns if we can.

Finally, can we add it as a menu item? Like this:

screen shot 2018-07-31 at 12 07 54

I think this will be very welcome.

Just looking at the screenshot, I think this is a great start. I like how Google Inbox shows their shortcuts:

screen shot 2018-07-31 at 12 10 59

Note the little gray background behind each shortcut button. We can probably use the kbd element for this: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd — possibly with a little minimalist styling.

Notably I like the relaxed row-like layout of keyboard shortcuts in Chrome OS:

screen shot 2018-07-31 at 12 10 18

Flagging also @karmatosed for thoughts.

@michelleweber
Copy link

(On the copy front, I'm not sure that you need the first sentence/subhead in each section; they bulk the modal up, but don't add any info that's not already there in the title and instructions. It also seems like the slash inserter could be part of the block shortcuts section, and I wonder if selection shortcuts can be part of global; then you have a simpler structure: general, block-specific, text-specific.)

@jasmussen jasmussen mentioned this pull request Jul 31, 2018
35 tasks
@karmatosed
Copy link
Member

I would many +1's the way Google show this as being a good pattern for us to follow. Thanks for all your work on this @talldan.

@talldan talldan force-pushed the add/keyboard-shortcut-modal branch from ef530a9 to 8bfcd16 Compare August 1, 2018 07:29
@talldan
Copy link
Contributor Author

talldan commented Aug 1, 2018

@jasmussen I've made some changes today based on the feedback. Here's how it looks now:

screen shot 2018-08-01 at 4 50 09 pm

I can't get the modal to show.

Looks like the editor needed focus for shortcut to work, I've fixed that now and it should work regardless.

Also, can we make it Shift+? instead?

The drawback with Shift+? is that it can't be used while typing, whereas Cmd+? can be. I'm happy to change it but thought I'd at least make you aware of why I went for Cmd+?.

Finally, can we add it as a menu item

I still need to work on this. Will pick that up next.

@jasmussen
Copy link
Contributor

The drawback with Shift+? is that it can't be used while typing, whereas Cmd+? can be. I'm happy to change it but thought I'd at least make you aware of why I went for Cmd+?.

Fair point. @karmatosed any thoughts? Go for Google consistency or go for the meta key?

Might meta+? conflict with other things?

Looking forward to the menu item!

Modal looks great. Awesome work. A few small things:

  1. "Select all" — might be cool to rephrase this so it notes that you can do multiple consecutive instances of this. For example
  • Select all blocks when no block is selected, or select all text in current text block ⌘A
  • Select all blocks from within a text block ⌘A ⌘A

Something like that, but perhaps with @michelleweber help.

  1. Typo: "Delete the select block(s)" — should be "selected" no?

On the ticket it was noted that ⌘+ duplicates for zoom, and ⌘D duplicates for bookmark. What other combos can we use here? ⌘+Shift+ + ? ⌘+Shift+D?

@earnjam
Copy link
Contributor

earnjam commented Aug 1, 2018

@talldan Design is looking good! I'm not a designer, but have two small points of feedback:

  1. The section headers sort of blend in with the shortcut descriptions making it hard to find the section you're looking for. Perhaps a heavier weight, or larger size would help?
  2. It's a bit difficult to trace across the line to the actual keyboard shortcut from the shorter descriptions. There is a lot of scanning eyes back and forth to read down the list.
    Google handles this in the design posted above by putting the shortcut on the left side and aligning them right so they are flush with the descriptions.
    This is what Cheatsheet for OSX does as well:
    image

Slack adds little grey lines to help easily align shortcut to description
image

@talldan
Copy link
Contributor Author

talldan commented Aug 2, 2018

Here's another update:
screen shot 2018-08-02 at 6 05 38 pm

I think I've addressed a lot of the feedback

  • Update copy and some of the shortcuts
  • Added some border between the rows
  • Add an option to the more menu to open the modal

@jasmussen - I haven't been able to find any issues with using Cmd+?, but I haven't checked Ctrl+? on Windows or Linux. I'll start looking at the best way to set up my windows box tomorrow.

@talldan talldan force-pushed the add/keyboard-shortcut-modal branch from ba70cfd to fe8a15c Compare August 2, 2018 09:56
@talldan
Copy link
Contributor Author

talldan commented Aug 2, 2018

Just spotted, I should also add the shortcut to the close modal button :)

@jasmussen
Copy link
Contributor

Love it. This is really coming together. Thanks for adding the menu item, modal works great.

I still can't get ⌘+? to work on my danish keyboard. Question mark is the shift option of the plus button, so if I press ⌘? I zoom in. If I press ⌘+Shift+? I open Chrome help.

I think we either need to find a different shortcut — perhaps one localized to each keyboard, or one that leverages a key that's in the same place in all locales. Or, just be fine with NOT having a keyboard shortcut for help.

Does TinyMCE have a keyboard shortcut for help, that we can use?

Also I think it's worth adding that if you are in text, and press ⌘A you first select all the text in that block, but if you press ⌘A again (with that text selected), you expand to select all blocks. It's a cool feature and worth noting.

@afercia
Copy link
Contributor

afercia commented Aug 2, 2018

Does TinyMCE have a keyboard shortcut for help, that we can use?

It uses Ctrl+Alt+H (Edit: however, I wonder if it would conflict with the classic block)

@afercia
Copy link
Contributor

afercia commented Aug 2, 2018

I'm not sure I see some of the keyboard shortcuts specific for keyboard navigation, e.g.:

'alt+f10': this.focusToolbar

and the ones to jump through the main landmark regions:

'ctrl+`': this.focusNextRegion
'ctrl+shift+`': this.focusPreviousRegion

Worth noting #8005 is going to add a couple additional shortcut.

I'd suggest to group al the shortcuts related to navigation under a group "Navigation".

@afercia
Copy link
Contributor

afercia commented Aug 2, 2018

I still can't get ⌘+? to work on my danish keyboard. Question mark is the shift option of the plus button, so if I press ⌘? I zoom in.

Can confirm it doesn't work with an Italian keyboard layout too. Worth noting using ? for the shortcut exposes to the same problem faced for other shortcuts: not all the keyboard layout have non-alphanumeric keys in the same location: https://it.wikipedia.org/wiki/File:Italian_Keyboard_layout.svg

screen shot 2018-08-02 at 14 37 14

Tested on Window Chrome:

  • pressing Ctrl + single quote or Ctrl + Shift + single quote doesn't do anything
  • what works, surprisingly, is Shift + ù

Given all the exploration made in #3218 I'd suggest to use two modifiers and a character-key.

@chrisvanpatten
Copy link
Contributor

chrisvanpatten commented Aug 2, 2018

The drawback with Shift+? is that it can't be used while typing, whereas Cmd+? can be. I'm happy to change it but thought I'd at least make you aware of why I went for Cmd+?.

FWIW, here are what a few popular web apps do (not that we should necessarily copy other web apps, but just for testing purposes)…

  • Gmail: Shift+/
  • Slack: Cmd+/
  • Google Docs: Cmd+/
  • GitHub: Shift+/

@afercia @jasmussen Out of curiosity, does cmd or shift + forward slash work for you? (Not "does it work for you" in an "are you okay with that shortcut" sense, but from a practical/usability sense, like is it literally possible on your keyboard layouts?)

@afercia
Copy link
Contributor

afercia commented Aug 2, 2018

No, also forward slash is placed differently in various keyboard layouts. See the link to the wikipedia page in #3218 (comment)

@talldan
Copy link
Contributor Author

talldan commented Aug 3, 2018

I spent too much time looking into this today, and have come to the conclusion that I don't think there's an easy way to bind either cmd/ctrl + ? or cmd/ctrl + / and have it work well across keyboard layouts.

Looking at how slack handles it, they use a different shortcut depending on the keyboard layout:
https://get.slack.help/hc/en-us/articles/115005429666-Manage-your-keyboard-layout

I tested and in Italian and Danish layouts they use cmd + .

Google docs doesn't bother handling this at all.

We could consider using cmd+k as the shortcut. Either on its own or as an additional shortcut.

? on its own may be possible, though it'd not be possible while typing in a block.

@jasmussen
Copy link
Contributor

I personally think it's okay if the help shortcut doesn't work while typing. In fact I also think it's okay to not have a shortcut at all — you can access the More menu using the keyboard and then invoke the help modal from there. Perhaps in order to ship the improvement that is this modal in the first place, it would be good to remove the shortcut altogether and possibly revisit later?

Did you try Ctrl+Alt+H which is what TinyMCE uses? Be sure to test also in the classic block.

@noisysocks
Copy link
Member

Is it easy to detect the keyboard layout and do what Slack does? Otherwise I reckon let's borrow the TinyMCE shortcut for now.

@jasmussen
Copy link
Contributor

Is it easy to detect the keyboard layout and do what Slack does?

I can't say with certainty because I'm not as skilled codewise as many of you are. And I would also love us to do this — it feels like the way superior solution. But my inkling is that it is extremely difficult, very onerous and time consuning, and prone to error as there are many many keyboard layouts we have to account for. Given how close we are to 5.0 deadlines, I'm thinking we should either keep things simple in order to ship improvements and iterate later, or just ship the improvements and be fine with not having any, or a clever, shortcut.

@talldan talldan force-pushed the add/keyboard-shortcut-modal branch from faf4976 to 3374379 Compare August 10, 2018 02:23
@talldan talldan removed Needs Copy Review Needs review of user-facing copy (language, phrasing) [Status] In Progress Tracking issues with work in progress labels Aug 10, 2018
Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! Great job.

@talldan talldan merged commit 0a21147 into master Aug 10, 2018
@talldan talldan deleted the add/keyboard-shortcut-modal branch August 10, 2018 02:57
const modifierKeys = castArray( modifiers );

await Promise.all(
modifierKeys.map( async ( modifier ) => page.keyboard.down( modifier ) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: There's no need for this to be an async function, since the await keyword is not used within the function's body.

@afercia
Copy link
Contributor

afercia commented Aug 26, 2018

Pressing ctl+option+h (shift+alt+h on windows/linux) displays a modal detailing keyboard shortcuts.

  • when VoiceOver is running, ctrl+option+h opens the VoiceOver help
  • shift+alt+h on Windows opens the Firefox and IE11 Help menu

Will open a separate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants