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

Better regions and shortcut #45157

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open

Better regions and shortcut #45157

wants to merge 2 commits into from

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Oct 20, 2022

What?

[Please note that the code is still a WIP, but it works for testing.]

As we are looking at changing tab behaviour in the editor (for list and code blocks), we need to strengthen other types of navigation.

There's two existing mechanisms:

  • Block navigation mode: press Escape.
  • Regions: press (Shift+)Ctrl+` or Ctrl+Alt+N/P, both of which I find hard to remember.

Proposal: additional regions with easier to remember shortcuts.

The additional regions would be:

  • The block toolbar
  • Navigation mode
  • Potentially before/after inserter for the selected block

In addition to that, offer easier to remember shortcuts:

  • Escape already enters Navigation mode, but does nothing further. Let it be used to enter the next region.
  • Shift+Escape should reverse cycle through the regions, so from the selected block, it enters the block toolbar, from there the interface header, and so on.

The (Shift+)Escape combination is a good indicator that it can be used to cycle through the regions, just like (Shift+)Tab can be used to cycle through tabbable elements.

But Ella, won't Escape clash with existing behaviour?

When a block is selected and focussed, we already use it for Navigation mode, which is now baked in the regions.

In other places, it can be used for closing popovers and modals, but that's fine. First the popover or modal must be closed before you can continue cycling through the regions. It makes perfect sense to me.

The main regions can be seen as the roundabout on which (Shift+)Escape can be used to navigate. (Shift+)Tab (default) or Arrow keys (navigation mode, toolbars) can be used to navigate more granularly.

Why?

We need a solid method to navigate the editor because (Shift+)Tab may no longer work when a block is focussed. A single unified way that is easy to remember will benefit all users greatly.

How?

Testing Instructions

Select a block. Test Escape and Shift+Escape shortcuts.

Screenshots or screencast

better-regions

@ellatrix ellatrix added the [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... label Oct 20, 2022
@github-actions
Copy link

github-actions bot commented Oct 20, 2022

Size Change: +3.45 kB (0%)

Total Size: 1.28 MB

Filename Size Change
build/block-editor/index.min.js 169 kB +867 B (+1%)
build/block-editor/style-rtl.css 15.8 kB +5 B (0%)
build/block-editor/style.css 15.8 kB +4 B (0%)
build/block-library/blocks/button/style-rtl.css 532 B +9 B (+2%)
build/block-library/blocks/button/style.css 532 B +9 B (+2%)
build/block-library/blocks/comment-template/style-rtl.css 199 B +12 B (+6%) 🔍
build/block-library/blocks/comment-template/style.css 198 B +13 B (+7%) 🔍
build/block-library/index.min.js 192 kB +571 B (0%)
build/block-library/style-rtl.css 12.3 kB +8 B (0%)
build/block-library/style.css 12.3 kB +8 B (0%)
build/components/index.min.js 202 kB -48 B (0%)
build/edit-post/index.min.js 31.8 kB +111 B (0%)
build/edit-site/index.min.js 58 kB +109 B (0%)
build/edit-site/style-rtl.css 8.37 kB +3 B (0%)
build/edit-site/style.css 8.35 kB +4 B (0%)
build/edit-widgets/index.min.js 16.7 kB +17 B (0%)
build/editor/index.min.js 43.4 kB +1.75 kB (+4%)
build/preferences/index.min.js 1.33 kB -4 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 982 B
build/annotations/index.min.js 2.76 kB
build/api-fetch/index.min.js 2.26 kB
build/autop/index.min.js 2.14 kB
build/blob/index.min.js 475 B
build/block-directory/index.min.js 7.09 kB
build/block-directory/style-rtl.css 990 B
build/block-directory/style.css 991 B
build/block-editor/default-editor-styles-rtl.css 378 B
build/block-editor/default-editor-styles.css 378 B
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 150 B
build/block-library/blocks/audio/editor.css 150 B
build/block-library/blocks/audio/style-rtl.css 122 B
build/block-library/blocks/audio/style.css 122 B
build/block-library/blocks/audio/theme-rtl.css 126 B
build/block-library/blocks/audio/theme.css 126 B
build/block-library/blocks/avatar/editor-rtl.css 116 B
build/block-library/blocks/avatar/editor.css 116 B
build/block-library/blocks/avatar/style-rtl.css 84 B
build/block-library/blocks/avatar/style.css 84 B
build/block-library/blocks/block/editor-rtl.css 161 B
build/block-library/blocks/block/editor.css 161 B
build/block-library/blocks/button/editor-rtl.css 482 B
build/block-library/blocks/button/editor.css 482 B
build/block-library/blocks/buttons/editor-rtl.css 337 B
build/block-library/blocks/buttons/editor.css 337 B
build/block-library/blocks/buttons/style-rtl.css 332 B
build/block-library/blocks/buttons/style.css 332 B
build/block-library/blocks/calendar/style-rtl.css 239 B
build/block-library/blocks/calendar/style.css 239 B
build/block-library/blocks/categories/editor-rtl.css 84 B
build/block-library/blocks/categories/editor.css 83 B
build/block-library/blocks/categories/style-rtl.css 100 B
build/block-library/blocks/categories/style.css 100 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 406 B
build/block-library/blocks/columns/style.css 406 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-content/style-rtl.css 92 B
build/block-library/blocks/comment-content/style.css 92 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 840 B
build/block-library/blocks/comments/editor.css 839 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 636 B
build/block-library/blocks/cover/editor-rtl.css 612 B
build/block-library/blocks/cover/editor.css 613 B
build/block-library/blocks/cover/style-rtl.css 1.57 kB
build/block-library/blocks/cover/style.css 1.55 kB
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/embed/theme-rtl.css 126 B
build/block-library/blocks/embed/theme.css 126 B
build/block-library/blocks/file/editor-rtl.css 300 B
build/block-library/blocks/file/editor.css 300 B
build/block-library/blocks/file/style-rtl.css 253 B
build/block-library/blocks/file/style.css 254 B
build/block-library/blocks/file/view.min.js 346 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB
build/block-library/blocks/freeform/editor.css 2.44 kB
build/block-library/blocks/gallery/editor-rtl.css 948 B
build/block-library/blocks/gallery/editor.css 950 B
build/block-library/blocks/gallery/style-rtl.css 1.53 kB
build/block-library/blocks/gallery/style.css 1.53 kB
build/block-library/blocks/gallery/theme-rtl.css 108 B
build/block-library/blocks/gallery/theme.css 108 B
build/block-library/blocks/group/editor-rtl.css 394 B
build/block-library/blocks/group/editor.css 394 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 76 B
build/block-library/blocks/heading/style.css 76 B
build/block-library/blocks/html/editor-rtl.css 327 B
build/block-library/blocks/html/editor.css 329 B
build/block-library/blocks/image/editor-rtl.css 880 B
build/block-library/blocks/image/editor.css 880 B
build/block-library/blocks/image/style-rtl.css 627 B
build/block-library/blocks/image/style.css 630 B
build/block-library/blocks/image/theme-rtl.css 126 B
build/block-library/blocks/image/theme.css 126 B
build/block-library/blocks/latest-comments/style-rtl.css 284 B
build/block-library/blocks/latest-comments/style.css 284 B
build/block-library/blocks/latest-posts/editor-rtl.css 213 B
build/block-library/blocks/latest-posts/editor.css 212 B
build/block-library/blocks/latest-posts/style-rtl.css 463 B
build/block-library/blocks/latest-posts/style.css 462 B
build/block-library/blocks/list/style-rtl.css 88 B
build/block-library/blocks/list/style.css 88 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 507 B
build/block-library/blocks/media-text/style.css 505 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 705 B
build/block-library/blocks/navigation-link/editor.css 703 B
build/block-library/blocks/navigation-link/style-rtl.css 115 B
build/block-library/blocks/navigation-link/style.css 115 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 296 B
build/block-library/blocks/navigation-submenu/editor.css 295 B
build/block-library/blocks/navigation/editor-rtl.css 2.02 kB
build/block-library/blocks/navigation/editor.css 2.03 kB
build/block-library/blocks/navigation/style-rtl.css 2.17 kB
build/block-library/blocks/navigation/style.css 2.16 kB
build/block-library/blocks/navigation/view-modal.min.js 2.78 kB
build/block-library/blocks/navigation/view.min.js 443 B
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 363 B
build/block-library/blocks/page-list/editor.css 363 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 174 B
build/block-library/blocks/paragraph/editor.css 174 B
build/block-library/blocks/paragraph/style-rtl.css 279 B
build/block-library/blocks/paragraph/style.css 281 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 493 B
build/block-library/blocks/post-comments-form/style.css 493 B
build/block-library/blocks/post-date/style-rtl.css 61 B
build/block-library/blocks/post-date/style.css 61 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B
build/block-library/blocks/post-excerpt/editor.css 73 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B
build/block-library/blocks/post-excerpt/style.css 69 B
build/block-library/blocks/post-featured-image/editor-rtl.css 586 B
build/block-library/blocks/post-featured-image/editor.css 584 B
build/block-library/blocks/post-featured-image/style-rtl.css 315 B
build/block-library/blocks/post-featured-image/style.css 315 B
build/block-library/blocks/post-navigation-link/style-rtl.css 153 B
build/block-library/blocks/post-navigation-link/style.css 153 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 282 B
build/block-library/blocks/post-template/style.css 282 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 B
build/block-library/blocks/preformatted/style-rtl.css 103 B
build/block-library/blocks/preformatted/style.css 103 B
build/block-library/blocks/pullquote/editor-rtl.css 135 B
build/block-library/blocks/pullquote/editor.css 135 B
build/block-library/blocks/pullquote/style-rtl.css 326 B
build/block-library/blocks/pullquote/style.css 325 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 282 B
build/block-library/blocks/query-pagination/style.css 278 B
build/block-library/blocks/query-title/style-rtl.css 63 B
build/block-library/blocks/query-title/style.css 63 B
build/block-library/blocks/query/editor-rtl.css 439 B
build/block-library/blocks/query/editor.css 439 B
build/block-library/blocks/quote/style-rtl.css 213 B
build/block-library/blocks/quote/style.css 213 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/read-more/style-rtl.css 132 B
build/block-library/blocks/read-more/style.css 132 B
build/block-library/blocks/rss/editor-rtl.css 202 B
build/block-library/blocks/rss/editor.css 204 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 165 B
build/block-library/blocks/search/editor.css 165 B
build/block-library/blocks/search/style-rtl.css 409 B
build/block-library/blocks/search/style.css 406 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/separator/editor-rtl.css 146 B
build/block-library/blocks/separator/editor.css 146 B
build/block-library/blocks/separator/style-rtl.css 234 B
build/block-library/blocks/separator/style.css 234 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 464 B
build/block-library/blocks/shortcode/editor.css 464 B
build/block-library/blocks/site-logo/editor-rtl.css 490 B
build/block-library/blocks/site-logo/editor.css 490 B
build/block-library/blocks/site-logo/style-rtl.css 203 B
build/block-library/blocks/site-logo/style.css 203 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 116 B
build/block-library/blocks/site-title/editor.css 116 B
build/block-library/blocks/site-title/style-rtl.css 57 B
build/block-library/blocks/site-title/style.css 57 B
build/block-library/blocks/social-link/editor-rtl.css 184 B
build/block-library/blocks/social-link/editor.css 184 B
build/block-library/blocks/social-links/editor-rtl.css 674 B
build/block-library/blocks/social-links/editor.css 673 B
build/block-library/blocks/social-links/style-rtl.css 1.4 kB
build/block-library/blocks/social-links/style.css 1.39 kB
build/block-library/blocks/spacer/editor-rtl.css 322 B
build/block-library/blocks/spacer/editor.css 322 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 494 B
build/block-library/blocks/table/editor.css 494 B
build/block-library/blocks/table/style-rtl.css 611 B
build/block-library/blocks/table/style.css 609 B
build/block-library/blocks/table/theme-rtl.css 190 B
build/block-library/blocks/table/theme.css 190 B
build/block-library/blocks/tag-cloud/style-rtl.css 251 B
build/block-library/blocks/tag-cloud/style.css 253 B
build/block-library/blocks/template-part/editor-rtl.css 235 B
build/block-library/blocks/template-part/editor.css 235 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 87 B
build/block-library/blocks/verse/style.css 87 B
build/block-library/blocks/video/editor-rtl.css 691 B
build/block-library/blocks/video/editor.css 694 B
build/block-library/blocks/video/style-rtl.css 174 B
build/block-library/blocks/video/style.css 174 B
build/block-library/blocks/video/theme-rtl.css 126 B
build/block-library/blocks/video/theme.css 126 B
build/block-library/classic-rtl.css 162 B
build/block-library/classic.css 162 B
build/block-library/common-rtl.css 1.02 kB
build/block-library/common.css 1.02 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 11.2 kB
build/block-library/editor.css 11.2 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/reset-rtl.css 478 B
build/block-library/reset.css 478 B
build/block-library/theme-rtl.css 719 B
build/block-library/theme.css 722 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.83 kB
build/blocks/index.min.js 49.9 kB
build/components/style-rtl.css 11.3 kB
build/components/style.css 11.3 kB
build/compose/index.min.js 12.2 kB
build/core-data/index.min.js 15.5 kB
build/customize-widgets/index.min.js 11.3 kB
build/customize-widgets/style-rtl.css 1.38 kB
build/customize-widgets/style.css 1.38 kB
build/data-controls/index.min.js 653 B
build/data/index.min.js 8.08 kB
build/date/index.min.js 32.1 kB
build/deprecated/index.min.js 507 B
build/dom-ready/index.min.js 324 B
build/dom/index.min.js 4.7 kB
build/edit-navigation/index.min.js 16.1 kB
build/edit-navigation/style-rtl.css 3.99 kB
build/edit-navigation/style.css 4 kB
build/edit-post/classic-rtl.css 546 B
build/edit-post/classic.css 547 B
build/edit-post/style-rtl.css 7.13 kB
build/edit-post/style.css 7.13 kB
build/edit-widgets/style-rtl.css 4.34 kB
build/edit-widgets/style.css 4.34 kB
build/editor/style-rtl.css 3.62 kB
build/editor/style.css 3.61 kB
build/element/index.min.js 4.68 kB
build/escape-html/index.min.js 537 B
build/experiments/index.min.js 868 B
build/format-library/index.min.js 6.95 kB
build/format-library/style-rtl.css 571 B
build/format-library/style.css 571 B
build/hooks/index.min.js 1.64 kB
build/html-entities/index.min.js 448 B
build/i18n/index.min.js 3.77 kB
build/is-shallow-equal/index.min.js 527 B
build/keyboard-shortcuts/index.min.js 1.78 kB
build/keycodes/index.min.js 1.83 kB
build/list-reusable-blocks/index.min.js 2.13 kB
build/list-reusable-blocks/style-rtl.css 835 B
build/list-reusable-blocks/style.css 835 B
build/media-utils/index.min.js 2.93 kB
build/notices/index.min.js 963 B
build/nux/index.min.js 2.06 kB
build/nux/style-rtl.css 732 B
build/nux/style.css 728 B
build/plugins/index.min.js 1.94 kB
build/preferences-persistence/index.min.js 2.22 kB
build/primitives/index.min.js 933 B
build/priority-queue/index.min.js 1.58 kB
build/react-i18n/index.min.js 696 B
build/react-refresh-entry/index.min.js 8.44 kB
build/react-refresh-runtime/index.min.js 7.31 kB
build/redux-routine/index.min.js 2.74 kB
build/reusable-blocks/index.min.js 2.21 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 10.6 kB
build/server-side-render/index.min.js 1.77 kB
build/shortcode/index.min.js 1.53 kB
build/style-engine/index.min.js 1.46 kB
build/token-list/index.min.js 644 B
build/url/index.min.js 3.61 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 38.5 kB
build/vendors/react.min.js 4.34 kB
build/viewport/index.min.js 1.08 kB
build/warning/index.min.js 268 B
build/widgets/index.min.js 7.21 kB
build/widgets/style-rtl.css 1.18 kB
build/widgets/style.css 1.19 kB
build/wordcount/index.min.js 1.06 kB

compressed-size-action

Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

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

@ellatrix Thanks for exploring this and trying to find a global solution. However, we must not use escape or shift+escape for any reason going forward. This has nasty issues for accessibility on Windows and I am trying to back us out of this situation, not introduce more issues. Maybe look at using ctrl+f6 and ctrl+shift+f6?

Related PRs:

Thoughts?

@ellatrix
Copy link
Member Author

However, we must not use escape or shift+escape for any reason going forward. This has nasty issues for accessibility on Windows and I am trying to back us out of this situation, not introduce more issues.

Could you elaborate on this? We are using Escape already and it's super common for web apps to use this shortcut.

@alexstine
Copy link
Contributor

@ellatrix Okay, please bare with me, the logic behind this is non-existent.

  1. JAWS and NVDA on Windows have the two distinct modes as I've talked about before. One is a mode that sends all keyboard input to the application, this is called edit/focus mode depending on the screen reader on Windows. The other mode is called browse/virtual mode which allows you to move the screen reader cursor around the screen. Browse mode however does not move the system focus, that is why it we should go for edit/focus mode in Gutenberg because the editor relies on the system focus.
  2. As developers, we do not have control over the screen reader cursor, another reason to keep screen readers sending input to Gutenberg as normal keyboard events.
  3. Getting to the point. The escape key does something rather unique on Windows. This key is used to switch in to browse/virtual mode from edit/focus mode. Normally, when screen readers are in focus/edit mode, all the keyboard input remains going to the application. The escape key is the only difference. Screen readers intercept the escape event and enables browse/virtual mode. There is no way to prevent this in Gutenberg even with an event modification.

Further reading:

  1. https://webaim.org/articles/jaws/
  2. https://dequeuniversity.com/screenreaders/nvda-keyboard-shortcuts

As you can see, the escape key is really the only key we can for sure not use based on screen readers hijacking it's usage. If the screen reader were to switch in to browse/virtual mode every time we press escape to navigate to another region, it would get pretty out of hand quickly as users would have little clue as to why all the mode switching was occurring. Picture this:

  1. Screen reader focus is placed on a block.
  2. Press shift+escape to focus the block toolbar.
  3. The screen reader will switch to browse/virtual mode because of escape usage but then will switch back as it comes in contact with the role="toolbar". ARIA can force screen readers in to different modes which is why it is important to be careful with ARIA roles.

I do not expect you to ever have a good understanding of this from Mac because Voiceover does not work this way.

One more example, which is a current bug in NVDA only.

  1. Focus a block.
  2. Press escape to focus the next region.
  3. If the next region contains a button inside a certain ARIA role, NVDA will switch to browse mode automatically and will rely on the user to switch it back. This is why we switched the list view to be wrapped in role="application". Even though the role="treegrid" is supposed to force NVDA in to edit/focus mode so our arrow keys can navigate the tree grid, when focus is placed on the options button for the block, the mode changes back to browse mode due to the bug. This causes our input to no longer be sent to the tree grid and there for it becomes essentially useless.

Related issues:

  1. List view: Certain screen readers still switch modes when options button receives focus #43729
  2. Unable to edit blocks once they've been inserted into content while using a screen reader #29526 (comment)

Sorry this is so hard to understand but you are going to have to trust me that this is not a good idea. Just because other applications use it does not make it right. I could list hundreds of problems with Google Docs, Slides, etc. Probably not the answer you were looking for, but hope it helps.

Thanks.

@ellatrix
Copy link
Member Author

So we shouldn't be using Escape ever? How do you suggest we close modals, popovers etc?

@alexstine
Copy link
Contributor

@ellatrix Ah, you found the only use for escape in applications. Using escape inside a modal is okay because the screen reader is already likely in browse mode anyway. As far as menus go, sometimes depending on the markup, escape on first press does not work with screen readers because of the mode switching. Sometimes it takes 1 escape press to switch to browse mode and 1 escape press to close the menu. I agree, it doesn't make sense because in browse mode keys are not sent to the application, but escape seems to have always had some weird behavior this way.

@ellatrix
Copy link
Member Author

I don't get it. If they key down event is not sent to the application in browse mode, how can the modal be closed on Escape?

@ellatrix
Copy link
Member Author

I'm worried that we start to optimise too much for screen readers while we do provide alternatives to use. From what you're saying it doesn't hurt allow the usage of Escape, it's just that you cannot use it on Windows. In that case, you can still use the old shortcuts to navigate regions. I'm not removing those.

@ellatrix
Copy link
Member Author

In fact, this PR is actually adding two other ways to get to navigation mode with the current region shortcuts.

@alexstine
Copy link
Contributor

@ellatrix Answers.

I don't get it. If they key down event is not sent to the application in browse mode, how can the modal be closed on Escape?

Yeah, I believe it is considered to be a navigational key and that is why it works. Just like tab. Tab key really does not act that differently between the different modes. The letters on the keyboard do, they could be used to jump to headings, links, lists, edit fields, etc. The arrow keys move the screen reader cursor in browse mode but allow the application control in edit/focus mode. Some keys operate almost the same way in either mode and some do not.

I'm worried that we start to optimise too much for screen readers while we do provide alternatives to use. From what you're saying it doesn't hurt allow the usage of Escape, it's just that you cannot use it on Windows. In that case, you can still use the old shortcuts to navigate regions. I'm not removing those.

Agreed to a point but designing around accessibility and screen readers is something that should be more important then it currently is. As devs, we should be making things easy to use for everyone and ensuring everyone has the same experience. Trust me, I did not wake up one day and say I want all the problems that come with a screen reader just to have some level of independence online. If we document escape key as a working solution, we'll find out real quick what types of problems those introduce for screen reader users. For other alternatives, I'll quote what you said.

Regions: press (Shift+)Ctrl+` or Ctrl+Alt+N/P, both of which I find hard to remember.

It is the edge of a slippery slope. You find those hard to remember but because escape would not work well on Windows, they are okay for the screen reader users.

Another thing to think about is how this might tie in with the list view. I just do not find the block navigation 100% necessary any longer and it would be great to working towards something everyone can use without having to maintain two systems that do essentially the same thing. List view and navigation mode.

Thanks.

@alexstine alexstine added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Needs Accessibility Feedback Need input from accessibility [a11y] Keyboard & Focus labels Oct 21, 2022
@ellatrix
Copy link
Member Author

Yeah, I believe it is considered to be a navigational key and that is why it works.

This is where I'm not following. So Escape does work in browse mode in Windows? So then it is fine?

@alexstine
Copy link
Contributor

@ellatrix

This is where I'm not following. So Escape does work in browse mode in Windows? So then it is fine?

Not exactly. Escape is a multi-function key in Windows depending on the screen reader. JAWS for example has the most trouble with this because it is directly responsible for switching modes. This is one of the developers of JAWS echoing the same. #29526 (comment)

The ctrl+f6 and ctrl+shift+f6 shortcuts are used in many browser-based applications and f6/shift+f6 is used in many Windows/Mac apps for navigation. I suggest this shortcut because it does not have any effect on screen reader mode switching and it is getting to be quite a well-respected navigational shortcut in the screen reader community.

Let me put it this way. If there was another key other than the escape key that could close menus and dialogs, we'd probably use it. Not knowing as a screen reader user if escape will switch modes or close the modal you are currently in is a confusing situation. Picture this example.

  1. Start JAWS on Windows.
  2. Open a dialog with a form inside of it.
  3. If you are typing in to the form, this is in edit/focus mode of the screen reader that way keyboard characters get sent to the form field.
  4. If I decide I do not want to be in the dialog any longer, I press escape. Because I am currently editing a form field, this puts my screen reader in to browse mode because that is what escape does.
  5. Another escape key press will close the dialog.
  6. Escape is a multi-function key and behavior is unpredictable. Just know that in Windows screen readers it will always switch modes but the order in which something gets closed or a mode switch is not predictable.
  7. If everyone could agree on a better keyboard shortcut to always close modals, menus, etc. I think it would have happened already.

Hopefully this explains a bit more.

@ellatrix
Copy link
Member Author

How do you go back to entering edit/focus mode after pressing Escape and going to browse mode?

@ellatrix
Copy link
Member Author

Another question: you mention that Ctrl+F6 is used for browser based applications. Why are we currently using Alt+F6? If we were to use Ctrl+F6, would this translate to Cmd+F6 on Mac? And why can't we plainly use F6? Does that clash with browser shortcuts?

@alexstine
Copy link
Contributor

@ellatrix

How do you go back to entering edit/focus mode after pressing Escape and going to browse mode?

  • NVDA: NVDA modifier+space. NVDA modifier by default is caps lock and insert. The mode can also switch if it comes in contact with proper ARIA role but this behavior is tricky and not always followed.
  • JAWS: To my knowledge, there is not a way to force JAWS back in to focus mode without coming in contact with the stated proper ARIA role. It is a slightly trickier screen reader with dynamic sites or sites that do not follow A11Y perfectly. You can always switch to browse mode in JAWS with escape, but not back to focus mode.

Another question: you mention that Ctrl+F6 is used for browser based applications. Why are we currently using Alt+F6? If we were to use Ctrl+F6, would this translate to Cmd+F6 on Mac? And why can't we plainly use F6? Does that clash with browser shortcuts?

So, f6 does clash with browser behavior. I am not sure if it does or not on Mac, but best guess would be yes. By default, f6 will move the focus around the toolbar, tabs bar, main content, etc. Where are we currently using alt+f6? I think Slack used ctrl+f6 but I think the whole idea is just to call some variation of f6 a navigation shortcut. In Slack desktop client, f6 alone is used because it is a native application they wrote. I think Teams uses ctrl+f6 on the web and the desktop client for consistency. I see no problem with using alt+f6 if that is easier.

Tagging @MarcoZehe to help explain some finer points if time provides.

  1. Why certain keys can cause mode switch in NVDA/JAWS and others do not.
  2. Using escape as a region navigation key.

I know the basics of how this stuff works, Marco might be able to give us a look at why it works this way.

Your next question might likely be if switching from modes is so easy, why am I pushing back so hard on it? Because, blind people rarely receive equal education to sighted people in the US. It is a painful fact but I watched it myself. I graduated with many who barely new how to check their email so when I start these types of discussions, I do so to try to make things incredibly simple with odds that are against us. Others on the project have been known to disagree, but I do not think it is our place to run an educational program for screen reader users. At least, not for just using Gutenberg if that makes sense. All for giving back, but that to me, is the wrong way to go about it.

Thanks.

@ellatrix
Copy link
Member Author

@alexstine Apologies, I confused it with Alt+F10. We're currently using Alt+F10 to focus the block toolbar. If we're adding Ctrl+F6 and Shift+Ctrl+F6 to navigate regions (which now includes the block toolbar), this could be removed, or we make Alt+F10 another alias for navigating regions (so it doesn't stop working).

Another question is whether the block toolbar should be positioned before or after the block in the DOM. This matters because positioning it after means using Ctrl+F6 and positioning it before means using Shift+Ctrl+F6. Some people are of the opinion though that the DOM position should be close to the visual position, and the block toolbar does appear just above the block.

I don't care much either way. It is something to keep in mind though if we'd consider merging List View and Navigation Mode. The position of List View would matter in how it's accessed.

@ellatrix
Copy link
Member Author

While I don't mind adding Ctrl+F6 for consistency with other applications, I don't really find it easier to use than the other shortcuts we have. Maybe it's even slightly worse: now I have to press 3 keys to move forwards and 4 keys to move backwards, because I also have to press Fn. In addition, I often forget which F number exactly I have to press, so I end up trying a few. I've been having this problem with Alt+F10 for focussing the block toolbar. My hope was to have something easy to remember that also makes sense in this context: when you're "stuck" in the editor with Tab not working, you can press Escape to navigate out of it and continue onwards to different regions. This also fits with the existing Escape shortcut for going to Navigation Mode.

Here's three alternatives:

  • We can try something similar to what macOS does natively for the Fn key, but then for Cmd (or Ctrl): when you solely press Cmd, navigate to the next region. (Shift+Cmd for navigating to the previous region.) Not when Cmd is pressed in combination with another key of course, and neither when Cmd was pressed for too long. This is exactly what macOS does for the Fn/Globe key: it's dual purpose to act as a modifier to the F keys, and the open the character viewer ("emoji and symbols") when pressed quickly without any modifiers.
  • Use modifiers with Escape: this could be Shift, Ctrl or Alt. Not sure which one would makes sense for moving forwards or backwards.
  • Use modifiers with Tab. This is already a crowded space and we'd have to change it depending on OS. For Mac the only free one is Alt+Tab. (Cmd+Tab is used to cycle through open native applications and Ctrl+Tab in browsers is used to cycle through browser tabs.) For Windows, Alt+Tab cycles through native applications, Ctrl+Tab also through browser tabs, so I guess the only option left on Windows is Ctrl+Alt+Tab? Not sure what other options there are here.

I'm just trying to be creative so that it's easier for everyone to navigate regions. :)

@alexstine
Copy link
Contributor

@ellatrix

  1. The alt+f10 is a tricky one because this is a common shortcut to find toolbars as well. Specifically formatting toolbars. For example, pressing f10 in Word will focus the formatting toolbar and I believe alt+f10 works in a lot of browser-based editors. Maybe we just don't change that for now until we're 100% sure how things should work with region navigation?
  2. The toolbar in the DOM should be much closer to the block itself. Right now, it appears above the title field in the DOM and it is something we should correct.
  3. The list view is a sidebar so I think it is okay if we let focus move users around based on our own conditions. My PR will greatly improve this flow once it goes in.

I do not fault anyone on struggling with shortcuts, it is a very hard task. If it helps, here are the ones we cannot use as they cause conflicts on Windows.

  1. Escape: Unless we're closing modals/menus/etc.
  2. Tab: Let's keep this a navigation key going forward.
  3. Shift: This generally means to move backwards, so makes little sense that it could do both.
  4. Delete/Backspace: Gutenberg already has too much wrapped up in this key.

I do see what you mean about the keyboard usage on Mac, to press f6 or shift+f6 is harder due to the function key. The things suggested on Windows would not be super easy either. Think about this one, ctrl+shift+escape? That is still 2 hands of work for most people.

How would you feel about ctrl+f6 and ctrl+shift+f6 if you kept the function keys displaying on Mac?

https://support.apple.com/en-us/HT204436

I mean, this would not be unreasonable. Mac is kind of clunky this way and I am always constantly adjusting Voiceover to work different ways per app. It is annoying but this is proof Apple is moving away from an accessibility-first approach. Seems like Windows is too, sigh...

@ellatrix
Copy link
Member Author

The alt+f10 is a tricky one because this is a common shortcut to find toolbars as well. Specifically formatting toolbars. For example, pressing f10 in Word will focus the formatting toolbar and I believe alt+f10 works in a lot of browser-based editors. Maybe we just don't change that for now until we're 100% sure how things should work with region navigation?

Agreed, we leave it as is. One thing we can improve here is allow Alt+F10 to cycle through toolbars if there are multiple (e.g. inline toolbar, block toolbar, link UI etc.)

The toolbar in the DOM should be much closer to the block itself. Right now, it appears above the title field in the DOM and it is something we should correct.

That is not possible. The closest position the toolbar can get is at the edge of the content. We can't insert the toolbar inside the content because it is not content but UI. This is the same as any other editor.

What I was wondering is whether the block toolbar should be positioned before or after the content.

Tab: Let's keep this a navigation key going forward.

When the editor has focus, this will no longer work in the future because we will change Tab to indent in lists and insert a tab character in code, preformatted, code editor etc. Hence this PR to improve alternatives to navigate/escape out of the editor content.

That is still 2 hands of work for most people.

It's still one key less in either direction by default (2 keys forward, 3 keys backward).

What do you think of the first alternative I mentioned? I will give this a try in a separate PR maybe.

For now let's more forward with this. I will fix the tests and polish the code.

@alexstine
Copy link
Contributor

@ellatrix

Agreed, we leave it as is. One thing we can improve here is allow Alt+F10 to cycle through toolbars if there are multiple (e.g. inline toolbar, block toolbar, link UI etc.)

We just need to figure out how to dynamically change the labels so that way users know what toolbar does what. Right now, it chooses the closest one so if it cycles through, users need to know where they are.

What I was wondering is whether the block toolbar should be positioned before or after the content.

That is fair. Put it at the start, before the content.

When the editor has focus, this will no longer work in the future because we will change Tab to indent in lists and insert a tab character in code, preformatted, code editor etc. Hence this PR to improve alternatives to navigate/escape out of the editor content.

Yes, but don't you envision this improving the navigation within dynamic blocks such as the image block as well? For example, accessing the Upload, Media Library, other tabbable content, etc. I think for blocks that do not include a specific use for the tab key such as the list or code blocks, it should have a roving tabindex pattern.

Looking forward to giving this a test!

@alexstine
Copy link
Contributor

@ellatrix So apparently Firefox uses ctrl+f6 and ctrl+shift+f6 as well. In theory, we could switch to just using f6/shift+f6 as we're going to need to throw event.preventDefault() I think to force browsers to leave this alone.

By any chance, is ctrl+< or ctrl+> being used anywhere? It does not follow the model of using shift key to go back, but it may be easier on Mac and Windows. Only if it does not conflict with an existing shortcut.

Thanks.

@alexstine
Copy link
Contributor

Testing in Chrome, ctrl+f6/ctrl+shift+f6 work fine. Strange.

@alexstine
Copy link
Contributor

Just to add, looks like Mattermost also uses a similar pattern.

https://docs.mattermost.com/channels/keyboard-accessibility.html

The ctrl+f6/ctrl+shift+f6 cycles regions in the browser. The tab/shift+tab navigates a regions content.

How hard would it be to make this fully work in Gutenberg? Seems this is the way of the future with JS apps. At least until someone finds another way for keyboard users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Needs Accessibility Feedback Need input from accessibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants