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

Avoid focusing blocks when inserting them into the canvas #28191

Merged
merged 25 commits into from
Feb 11, 2021

Conversation

youknowriad
Copy link
Contributor

@youknowriad youknowriad commented Jan 14, 2021

closes #26223

Despite what the title of the PR might suggest, this is a very impactful PR that changes a lot of things on how subtle things in the editor work.

  • The first thing is that if you insert a block using the inserter, it's not "focused" anymore, which allows the inserter to stay open. From a screen reader perspective, this is correct. Moving the focus was the thing forcing us to actually close the inserter.
  • The second thing is that before this PR, selecting a block meant necessarily focusing the block (at very few exceptions), this PR breaks this tight relationship. Basically, unless you ask to focus a block when you select it (by providing the initialPosition), we assume you just want to "select" a block in the data and not select it. This allows us to perform things like: scroll to the right position/selected block without necessarily moving the focus.
  • There are also some nice and important side effects of this change: previously we had a hook that allows us to scroll to the right position when multi-selecting, this hook now works for all kind of block selection and is "bundled" in block-editor. It was only enabled in the post editor previously.

So, it's very important to actually test the PR properly to ensure it's working as intended and that the new behavior makes sense for all kind of users.

@youknowriad youknowriad added [Feature] Inserter The main way to insert blocks using the + button in the editing interface Needs Design Feedback Needs general design feedback. Needs Accessibility Feedback Need input from accessibility labels Jan 14, 2021
@youknowriad youknowriad self-assigned this Jan 14, 2021
@github-actions
Copy link

github-actions bot commented Jan 14, 2021

Size Change: +1.29 kB (0%)

Total Size: 1.37 MB

Filename Size Change
build/annotations/index.js 3.78 kB +5 B (0%)
build/api-fetch/index.js 3.4 kB -1 B (0%)
build/autop/index.js 2.84 kB -1 B (0%)
build/block-directory/index.js 9.09 kB -3 B (0%)
build/block-editor/index.js 124 kB +250 B (0%)
build/block-editor/style-rtl.css 12.1 kB +10 B (0%)
build/block-editor/style.css 12.1 kB +10 B (0%)
build/block-library/blocks/navigation-link/editor-rtl.css 395 B +3 B (+1%)
build/block-library/blocks/navigation-link/editor.css 397 B +3 B (+1%)
build/block-library/blocks/navigation/editor-rtl.css 1.34 kB +10 B (+1%)
build/block-library/blocks/navigation/editor.css 1.34 kB +9 B (+1%)
build/block-library/blocks/navigation/style-rtl.css 195 B +8 B (+4%)
build/block-library/blocks/navigation/style.css 195 B +8 B (+4%)
build/block-library/blocks/template-part/editor-rtl.css 557 B -123 B (-18%) 👏
build/block-library/blocks/template-part/editor.css 556 B -123 B (-18%) 👏
build/block-library/editor-rtl.css 9.04 kB -65 B (-1%)
build/block-library/editor.css 9.03 kB -66 B (-1%)
build/block-library/index.js 145 kB +57 B (0%)
build/block-library/style-rtl.css 8.8 kB +11 B (0%)
build/block-library/style.css 8.8 kB +11 B (0%)
build/block-serialization-default-parser/index.js 1.88 kB -1 B (0%)
build/blocks/index.js 48.2 kB +3 B (0%)
build/components/index.js 270 kB +9 B (0%)
build/compose/index.js 11 kB -5 B (0%)
build/core-data/index.js 16.8 kB -27 B (0%)
build/customize-widgets/index.js 4.08 kB -2 B (0%)
build/data/index.js 8.86 kB -3 B (0%)
build/dom/index.js 4.94 kB +1 B (0%)
build/edit-navigation/index.js 10.5 kB -4 B (0%)
build/edit-navigation/style-rtl.css 1.12 kB +11 B (+1%)
build/edit-navigation/style.css 1.12 kB +12 B (+1%)
build/edit-post/index.js 307 kB -34 B (0%)
build/edit-site/index.js 25.4 kB +619 B (+3%)
build/edit-site/style-rtl.css 4.37 kB +334 B (+8%) 🔍
build/edit-site/style.css 4.37 kB +330 B (+8%) 🔍
build/edit-widgets/index.js 20 kB -7 B (0%)
build/editor/index.js 41.9 kB +40 B (0%)
build/format-library/index.js 6.77 kB +2 B (0%)
build/i18n/index.js 4.01 kB -1 B (0%)
build/keyboard-shortcuts/index.js 2.53 kB +1 B (0%)
build/keycodes/index.js 1.93 kB +5 B (0%)
build/media-utils/index.js 5.35 kB -1 B (0%)
build/notices/index.js 1.85 kB +1 B (0%)
build/plugins/index.js 2.54 kB -1 B (0%)
build/redux-routine/index.js 2.84 kB +1 B (0%)
build/reusable-blocks/index.js 2.92 kB +1 B (0%)
build/rich-text/index.js 13.4 kB -1 B (0%)
build/viewport/index.js 1.85 kB -3 B (0%)
build/wordcount/index.js 1.22 kB +1 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/blob/index.js 665 B 0 B
build/block-directory/style-rtl.css 1.01 kB 0 B
build/block-directory/style.css 1.01 kB 0 B
build/block-library/blocks/archives/editor-rtl.css 61 B 0 B
build/block-library/blocks/archives/editor.css 60 B 0 B
build/block-library/blocks/audio/editor-rtl.css 58 B 0 B
build/block-library/blocks/audio/editor.css 58 B 0 B
build/block-library/blocks/audio/style-rtl.css 103 B 0 B
build/block-library/blocks/audio/style.css 103 B 0 B
build/block-library/blocks/block/editor-rtl.css 161 B 0 B
build/block-library/blocks/block/editor.css 161 B 0 B
build/block-library/blocks/button/editor-rtl.css 475 B 0 B
build/block-library/blocks/button/editor.css 474 B 0 B
build/block-library/blocks/button/style-rtl.css 465 B 0 B
build/block-library/blocks/button/style.css 464 B 0 B
build/block-library/blocks/buttons/editor-rtl.css 233 B 0 B
build/block-library/blocks/buttons/editor.css 233 B 0 B
build/block-library/blocks/buttons/style-rtl.css 303 B 0 B
build/block-library/blocks/buttons/style.css 303 B 0 B
build/block-library/blocks/calendar/style-rtl.css 208 B 0 B
build/block-library/blocks/calendar/style.css 208 B 0 B
build/block-library/blocks/categories/editor-rtl.css 84 B 0 B
build/block-library/blocks/categories/editor.css 83 B 0 B
build/block-library/blocks/categories/style-rtl.css 79 B 0 B
build/block-library/blocks/categories/style.css 79 B 0 B
build/block-library/blocks/code/style-rtl.css 90 B 0 B
build/block-library/blocks/code/style.css 90 B 0 B
build/block-library/blocks/columns/editor-rtl.css 190 B 0 B
build/block-library/blocks/columns/editor.css 190 B 0 B
build/block-library/blocks/columns/style-rtl.css 421 B 0 B
build/block-library/blocks/columns/style.css 421 B 0 B
build/block-library/blocks/cover/editor-rtl.css 390 B 0 B
build/block-library/blocks/cover/editor.css 389 B 0 B
build/block-library/blocks/cover/style-rtl.css 1.25 kB 0 B
build/block-library/blocks/cover/style.css 1.25 kB 0 B
build/block-library/blocks/embed/editor-rtl.css 486 B 0 B
build/block-library/blocks/embed/editor.css 486 B 0 B
build/block-library/blocks/embed/style-rtl.css 396 B 0 B
build/block-library/blocks/embed/style.css 395 B 0 B
build/block-library/blocks/file/editor-rtl.css 199 B 0 B
build/block-library/blocks/file/editor.css 198 B 0 B
build/block-library/blocks/file/style-rtl.css 248 B 0 B
build/block-library/blocks/file/style.css 248 B 0 B
build/block-library/blocks/freeform/editor-rtl.css 2.45 kB 0 B
build/block-library/blocks/freeform/editor.css 2.45 kB 0 B
build/block-library/blocks/gallery/editor-rtl.css 679 B 0 B
build/block-library/blocks/gallery/editor.css 679 B 0 B
build/block-library/blocks/gallery/style-rtl.css 1.07 kB 0 B
build/block-library/blocks/gallery/style.css 1.06 kB 0 B
build/block-library/blocks/group/editor-rtl.css 318 B 0 B
build/block-library/blocks/group/editor.css 317 B 0 B
build/block-library/blocks/group/style-rtl.css 57 B 0 B
build/block-library/blocks/group/style.css 57 B 0 B
build/block-library/blocks/heading/editor-rtl.css 129 B 0 B
build/block-library/blocks/heading/editor.css 129 B 0 B
build/block-library/blocks/heading/style-rtl.css 76 B 0 B
build/block-library/blocks/heading/style.css 76 B 0 B
build/block-library/blocks/html/editor-rtl.css 281 B 0 B
build/block-library/blocks/html/editor.css 281 B 0 B
build/block-library/blocks/image/editor-rtl.css 717 B 0 B
build/block-library/blocks/image/editor.css 716 B 0 B
build/block-library/blocks/image/style-rtl.css 477 B 0 B
build/block-library/blocks/image/style.css 478 B 0 B
build/block-library/blocks/latest-comments/editor-rtl.css 159 B 0 B
build/block-library/blocks/latest-comments/editor.css 158 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 269 B 0 B
build/block-library/blocks/latest-comments/style.css 269 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B 0 B
build/block-library/blocks/latest-posts/editor.css 137 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 523 B 0 B
build/block-library/blocks/latest-posts/style.css 522 B 0 B
build/block-library/blocks/list/editor-rtl.css 65 B 0 B
build/block-library/blocks/list/editor.css 65 B 0 B
build/block-library/blocks/list/style-rtl.css 63 B 0 B
build/block-library/blocks/list/style.css 63 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 191 B 0 B
build/block-library/blocks/media-text/editor.css 191 B 0 B
build/block-library/blocks/media-text/style-rtl.css 535 B 0 B
build/block-library/blocks/media-text/style.css 532 B 0 B
build/block-library/blocks/more/editor-rtl.css 434 B 0 B
build/block-library/blocks/more/editor.css 434 B 0 B
build/block-library/blocks/navigation-link/style-rtl.css 704 B 0 B
build/block-library/blocks/navigation-link/style.css 702 B 0 B
build/block-library/blocks/nextpage/editor-rtl.css 395 B 0 B
build/block-library/blocks/nextpage/editor.css 395 B 0 B
build/block-library/blocks/page-list/editor-rtl.css 214 B 0 B
build/block-library/blocks/page-list/editor.css 214 B 0 B
build/block-library/blocks/page-list/style-rtl.css 527 B 0 B
build/block-library/blocks/page-list/style.css 526 B 0 B
build/block-library/blocks/paragraph/editor-rtl.css 109 B 0 B
build/block-library/blocks/paragraph/editor.css 109 B 0 B
build/block-library/blocks/paragraph/style-rtl.css 273 B 0 B
build/block-library/blocks/paragraph/style.css 273 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 209 B 0 B
build/block-library/blocks/post-author/editor.css 209 B 0 B
build/block-library/blocks/post-author/style-rtl.css 183 B 0 B
build/block-library/blocks/post-author/style.css 184 B 0 B
build/block-library/blocks/post-comments-form/style-rtl.css 250 B 0 B
build/block-library/blocks/post-comments-form/style.css 250 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 139 B 0 B
build/block-library/blocks/post-content/editor.css 139 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B 0 B
build/block-library/blocks/post-excerpt/editor.css 73 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 338 B 0 B
build/block-library/blocks/post-featured-image/editor.css 338 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 100 B 0 B
build/block-library/blocks/post-featured-image/style.css 100 B 0 B
build/block-library/blocks/preformatted/style-rtl.css 63 B 0 B
build/block-library/blocks/preformatted/style.css 63 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 183 B 0 B
build/block-library/blocks/pullquote/editor.css 183 B 0 B
build/block-library/blocks/pullquote/style-rtl.css 316 B 0 B
build/block-library/blocks/pullquote/style.css 316 B 0 B
build/block-library/blocks/query-loop/editor-rtl.css 90 B 0 B
build/block-library/blocks/query-loop/editor.css 89 B 0 B
build/block-library/blocks/query-loop/style-rtl.css 315 B 0 B
build/block-library/blocks/query-loop/style.css 317 B 0 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B 0 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B 0 B
build/block-library/blocks/query-pagination/editor-rtl.css 270 B 0 B
build/block-library/blocks/query-pagination/editor.css 262 B 0 B
build/block-library/blocks/query-pagination/style-rtl.css 168 B 0 B
build/block-library/blocks/query-pagination/style.css 168 B 0 B
build/block-library/blocks/query/editor-rtl.css 159 B 0 B
build/block-library/blocks/query/editor.css 160 B 0 B
build/block-library/blocks/quote/editor-rtl.css 61 B 0 B
build/block-library/blocks/quote/editor.css 61 B 0 B
build/block-library/blocks/quote/style-rtl.css 169 B 0 B
build/block-library/blocks/quote/style.css 169 B 0 B
build/block-library/blocks/rss/editor-rtl.css 201 B 0 B
build/block-library/blocks/rss/editor.css 202 B 0 B
build/block-library/blocks/rss/style-rtl.css 290 B 0 B
build/block-library/blocks/rss/style.css 290 B 0 B
build/block-library/blocks/search/editor-rtl.css 165 B 0 B
build/block-library/blocks/search/editor.css 165 B 0 B
build/block-library/blocks/search/style-rtl.css 342 B 0 B
build/block-library/blocks/search/style.css 344 B 0 B
build/block-library/blocks/separator/editor-rtl.css 99 B 0 B
build/block-library/blocks/separator/editor.css 99 B 0 B
build/block-library/blocks/separator/style-rtl.css 236 B 0 B
build/block-library/blocks/separator/style.css 236 B 0 B
build/block-library/blocks/shortcode/editor-rtl.css 504 B 0 B
build/block-library/blocks/shortcode/editor.css 504 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 201 B 0 B
build/block-library/blocks/site-logo/editor.css 201 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 117 B 0 B
build/block-library/blocks/site-logo/style.css 117 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 164 B 0 B
build/block-library/blocks/social-link/editor.css 165 B 0 B
build/block-library/blocks/social-links/editor-rtl.css 696 B 0 B
build/block-library/blocks/social-links/editor.css 696 B 0 B
build/block-library/blocks/social-links/style-rtl.css 1.37 kB 0 B
build/block-library/blocks/social-links/style.css 1.37 kB 0 B
build/block-library/blocks/spacer/editor-rtl.css 302 B 0 B
build/block-library/blocks/spacer/editor.css 302 B 0 B
build/block-library/blocks/spacer/style-rtl.css 48 B 0 B
build/block-library/blocks/spacer/style.css 48 B 0 B
build/block-library/blocks/subhead/editor-rtl.css 99 B 0 B
build/block-library/blocks/subhead/editor.css 99 B 0 B
build/block-library/blocks/subhead/style-rtl.css 80 B 0 B
build/block-library/blocks/subhead/style.css 80 B 0 B
build/block-library/blocks/table/editor-rtl.css 489 B 0 B
build/block-library/blocks/table/editor.css 489 B 0 B
build/block-library/blocks/table/style-rtl.css 386 B 0 B
build/block-library/blocks/table/style.css 386 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 118 B 0 B
build/block-library/blocks/tag-cloud/editor.css 118 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 94 B 0 B
build/block-library/blocks/tag-cloud/style.css 94 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B 0 B
build/block-library/blocks/text-columns/editor.css 95 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 166 B 0 B
build/block-library/blocks/text-columns/style.css 166 B 0 B
build/block-library/blocks/verse/editor-rtl.css 62 B 0 B
build/block-library/blocks/verse/editor.css 62 B 0 B
build/block-library/blocks/verse/style-rtl.css 87 B 0 B
build/block-library/blocks/verse/style.css 87 B 0 B
build/block-library/blocks/video/editor-rtl.css 504 B 0 B
build/block-library/blocks/video/editor.css 503 B 0 B
build/block-library/blocks/video/style-rtl.css 193 B 0 B
build/block-library/blocks/video/style.css 193 B 0 B
build/block-library/common-rtl.css 1.01 kB 0 B
build/block-library/common.css 1.01 kB 0 B
build/block-library/theme-rtl.css 748 B 0 B
build/block-library/theme.css 748 B 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/components/style-rtl.css 15.5 kB 0 B
build/components/style.css 15.5 kB 0 B
build/customize-widgets/style-rtl.css 168 B 0 B
build/customize-widgets/style.css 168 B 0 B
build/data-controls/index.js 827 B 0 B
build/date/index.js 31.8 kB 0 B
build/deprecated/index.js 769 B 0 B
build/dom-ready/index.js 570 B 0 B
build/edit-post/style-rtl.css 6.79 kB 0 B
build/edit-post/style.css 6.78 kB 0 B
build/edit-widgets/style-rtl.css 3.2 kB 0 B
build/edit-widgets/style.css 3.2 kB 0 B
build/editor/editor-styles-rtl.css 543 B 0 B
build/editor/editor-styles.css 545 B 0 B
build/editor/style-rtl.css 3.89 kB 0 B
build/editor/style.css 3.89 kB 0 B
build/element/index.js 4.61 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/style-rtl.css 637 B 0 B
build/format-library/style.css 639 B 0 B
build/hooks/index.js 2.28 kB 0 B
build/html-entities/index.js 622 B 0 B
build/is-shallow-equal/index.js 699 B 0 B
build/list-reusable-blocks/index.js 3.15 kB 0 B
build/list-reusable-blocks/style-rtl.css 629 B 0 B
build/list-reusable-blocks/style.css 628 B 0 B
build/nux/index.js 3.41 kB 0 B
build/nux/style-rtl.css 731 B 0 B
build/nux/style.css 727 B 0 B
build/primitives/index.js 1.42 kB 0 B
build/priority-queue/index.js 791 B 0 B
build/react-i18n/index.js 1.45 kB 0 B
build/server-side-render/index.js 2.77 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 3.01 kB 0 B
build/warning/index.js 1.14 kB 0 B

compressed-size-action

@jasmussen
Copy link
Contributor

You're my favorite, Riad. This is great. This is what I see:

inserter

On this one:

The second thing is that before this PR, selecting a block meant necessarily focusing the block (at very few exceptions), this PR breaks this tight relationship. Basically, unless you ask to focus a block when you select it (by providing the initialPosition), we assume you just want to "select" a block in the data and not select it. This allows us to perform things like: scroll to the right position/selected block without necessarily moving the focus.

When you use the term "blocks" here, you're referring to blocks in the block library, correct? Because focus appears to behave just fine in-canvas:

focus

High level, I see only upsides to this. It feels like it's closer than ever to getting the right balance of making it easy to insert blocks, not covering content, easy to close (click outside or press Escape), while still providing ample space for the blocks.

I look forward to additional eyes on this, but I'm all excitement here.

@youknowriad
Copy link
Contributor Author

When you use the term "blocks" here, you're referring to blocks in the block library, correct?

No, I meant blocks in the caves (block instances). But I did try to make the writing flow interactions work like today, so that's why you don't see major changes there.

@jasmussen
Copy link
Contributor

No, I meant blocks in the caves (block instances). But I did try to make the writing flow interactions work like today, so that's why you don't see major changes there.

Gotcha. If it works as it should, then I'd not see any problem. Anything in particular to look for?

@youknowriad
Copy link
Contributor Author

Anything in particular to look for?

All interactions that can insert or replace blocks.

@youknowriad
Copy link
Contributor Author

youknowriad commented Jan 14, 2021

This should also be tested with screen readers to see if the new flows still make sense.

@youknowriad youknowriad requested a review from mtias January 14, 2021 12:05
@shaunandrews
Copy link
Contributor

This feels sooooooooooooooooooooo much better.

  • All seems well with inserting blocks, both at the root of the document and within containers like Columns.
  • I did notice that I can't add multiple Paragraph blocks; I can insert every other block multiple times.
  • Adding patterns seems broken. I can add one, but then selecting another triggers a snackbar notice, but doesn't actually add the pattern to the document.

@alexstine
Copy link
Contributor

Here is my feedback:

  • When selecting Add Block, focus is no longer placed in the block inserter.
  • After adding a block, the focus is placed on Add Block instead of remaining in the inserter.

This shows bad signs of not working with keyboard navigation.

Tested on Windows 7, Firefox, and NV Access (NVDA) screen reader.

Thanks.

@youknowriad
Copy link
Contributor Author

@alexstine Thanks for testing.

I don't seem to recreate the behavior you're suggesting. When I hit "enter" on "Add block", the inserter is opened and the focus moves to its search form and when I insert a block, the focus just stays where it is in the inserter for me.

That said, I'm testing on MacOS and don't have access to the same setup as you.

@youknowriad
Copy link
Contributor Author

@shaunandrews Block patterns insertion is fixed.

@shaunandrews
Copy link
Contributor

I tried this out using VoiceOver on my Mac, and notice that once I closed the sidebar (using the esc key) my focus remained "floating." I expected it to move into the canvas, perhaps focused on the last block added.

image

That black, floating square is the VoiceOver focus indicator; You can see how it still thinks the inserter has focus, even after I closed the sidebar.

@youknowriad
Copy link
Contributor Author

I closed the sidebar (using the esc key) my focus remained "floating."

What do you mean "floating"? For me it should move the "plus button" and work consistently with all popovers.

@Ryokuhi
Copy link

Ryokuhi commented Jan 15, 2021

This Pull Request was discussed today during the weekly accessibility team's meeting.

In general, the team asks for some time to test how this feature works with assistive technologies, especially screen readers, and with keyboard-only navigation.

The main point of the discussion is that it should be clear to the user what happens after the inserter is closed: @alexstine reported that he couldn't figure it out, so other assistive technologies users can be confused as well.

As explained by @youknowriad during the meeting, the new implementation of the inserter follows a popover model: when the inserter is closed, focus moves to the position from where the inserter was opened. Before this Pull Request, after each block is added from the inserter, focus moves to the added block.

During discussion, two possible patterns emerged on how to handle focus when the inserter is closed.

  • Focus moves back to the button that opened the inserter.
  • Focus moves to the added blocks: in case more than one block is added, the team recommends to focus the first added block.
    Hopefully, testing will show which pattern is the best.

As the plan is to land this feature in WordPress 5.7, there isn't a lot of time ahead, given that at least some iteration is needed to solve the two bugs identified in @alexstine's comment above.
If more feedback is needed, we can discuss test results in one of the next weekly accessibility team's meetings.

@alexstine
Copy link
Contributor

I just tried this out again and here is my experience with another round of testing.

  1. Start with a paragraph block. Enter some text.
  2. Shift+Tab twice to Add Block button.
  3. Activate the button and now I am placed in the search bar of the block inserter.
  4. I search for list.
  5. I tab to the list block.
  6. Press Enter to insert.
  7. I hear a message that says "block inserted" even though I think it should have said "list block inserted." I remember this being something I've discovered previously to this PR so probably not a direct cause of this change.
  8. The block inserter remains open, but loses screen reader focus. The next time I press Tab, I land on View Posts link. However I can navigate back to the inserter using CTRL+`.
  9. When I finally Tab back to the blocks list, I am automatically in edit mode and this is probably bad UX. I can see defaulting to navigation mode after inserting a block, but not edit mode since we're not focusing the block any longer.
  10. The other odd thing I notice is the list block now appears before the paragraph block. Now it goes list block, paragraph block. I thought the block should insert after the paragraph block, not before.

I will say, if Escape key is used while inside the block inserter, focus does land back on Add Block as it is supposed to.

Anyway, this still seems very broken for Windows keyboard navigation. Tested in Firefox with NV Access.

Thanks.

@youknowriad youknowriad force-pushed the try/separate-block-selection-from-focus branch from 8719dbe to 59ecb9f Compare January 20, 2021 07:33
@youknowriad
Copy link
Contributor Author

@alexstine Thanks for expanding, I'm happy to fix the keyboard navigation issues.

Initially, I thought you were using the global inserter, that said, when trying the steps above (quick inserter), I still have a different behavior on step 8. For me the quick inserter does close itself and the focus is back to the block wrapper though.

I didn't intend to impact the quick inserter in this PR, so I'll check how different is it compared to master.

@youknowriad
Copy link
Contributor Author

The behavior of the quick inserter is restored in the last commit, how does this look?

@youknowriad youknowriad force-pushed the try/separate-block-selection-from-focus branch from 97437fd to 9f617c3 Compare February 10, 2021 07:34
@shaunandrews
Copy link
Contributor

Its really amazing to see the back-and-forth and continued iteration on this one. Kudos all around.

--

I've been playing with this for a while this morning, and have noticed some strange interactions.

  • If there are no blocks on my page, using the inserter to add one immediately closes the inserter after.
  • Sometimes, adding a paragraph block and then a heading block will immediately close the inserter.
  • Adding a Buttons block puts my cursor inside the first Button block and updates the list of available blocks, which feels broken.

Here's a video that shows these things happening:

Strange.Inserter.Interactions.mov

onSelect( item );
onSelect(
item,
isAppleOS() ? event.metaKey : event.ctrlKey
Copy link
Member

Choose a reason for hiding this comment

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

Don't we have logic for this in the keyboard package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't seem exposed, but definitely something we should expose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mmm, actually, it seems I could use isKeyboardEvent directly. Thanks Ella

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wasn't able to do on the "click" event, we'd need to expose isApple somehow.

@youknowriad
Copy link
Contributor Author

@shaunandrews the issues you raised should be fixed. Thanks for catching these.

@youknowriad youknowriad merged commit db8da15 into master Feb 11, 2021
@youknowriad youknowriad deleted the try/separate-block-selection-from-focus branch February 11, 2021 14:31
@youknowriad
Copy link
Contributor Author

Let's get this in Thank you all. Let me know if you notice any regressions.

@github-actions github-actions bot added this to the Gutenberg 10.1 milestone Feb 11, 2021
noisysocks added a commit that referenced this pull request Feb 22, 2021
The import for this was added as part of #28191, but we do not wish to
cherry-pick the entirety of #28191.
noisysocks added a commit that referenced this pull request Feb 22, 2021
The import for this was added as part of #28191, but we do not wish to
cherry-pick the entirety of #28191.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface Needs Accessibility Feedback Need input from accessibility Needs Design Feedback Needs general design feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add setting to configure whether inserter sidebar remains open or not
8 participants