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

Implement Tabs in site-editor settings #56959

Merged
merged 10 commits into from Feb 2, 2024
Merged

Conversation

chad1008
Copy link
Contributor

@chad1008 chad1008 commented Dec 11, 2023

What?

Replace existing list-based tabs the new Tabs component in the site editor settings sidebar

Why?

The current implementation was necessary because our legacy TabPanel component was not granular enough to be applied in this sidebar, due in large part to the internals of the the ComplementaryArea the sidebar uses.

How?

Using the new, more granular sub-components of Tabs, we can render the appropriate parts of the UI via ComplementaryArea's slot/fill, and pass the Tabs context to those components as needed.

This implementation is very similar to the one used previously in #55360. The biggest difference is that in this implementation, in addition to making sure the editor sidebar is active, we also need to confirm that that the canvas itself is in edit mode. When the editor canvas switches from edit to view, all of the tabs are removed from the DOM (much like when the sidebar itself gets closed). When this happens, the component can't find the currently selected tab (which is tracked in interfaceStore) which causes an infinite loop as the component and the store argue with each other. Checking the canvas state before setting the current tab makes sure that loop doesn't happen.

One important note on this specific Tabs implementation is that in the editor sidebars a race condition exists where if no tab is selected, and then the Tab key is used to cycle through all of the existing blocks, the next press of Tab will move focus to the settings sidebar.

When that happens, two events fire independently of each other in this order:

  1. Focus moves from the final block to the currently active settings tab, which is Block
  2. interfaceStore detects that focus is no longer on a block. The sidebar is automatically switched over the the Post tab.

The net result from a user perspective is that pressing Tab that last time focuses one tab wile selecting the other. This feels really confusing, so we're adding a check to prevent that from happening.

Testing Instructions

  1. Launch the site editor and edit a template.
  2. In the sidebar test the document (i.e. Post/Template/etc.) and Block tabs.
  3. Confirm that each tab shows the correct content
  4. Select the Template tab
  5. In the canvas, click on a block and confirm that the Block tab is auto-selected with the correct content displayed
  6. Test opening and closing the sidebar, confirm there are no errors or crashes
  7. Test "Open Navigation" button (WP logo, top left of site editor) and confirm the editor canvas closes without errors or crashes. Repeat this test with the editor sidebar open as well as collapsed to make sure both work.
  8. Create a new, blank template. Don't use a pattern just start with a completely clean slate.
  9. Add one or two Heading blocks with some random text in them
  10. Click below your last block in the empty space on the canvas
  11. Press Tab to cycle through the blocks, and then once more to focus the settings sidebar
  12. Confirm that when focus leaves the last block, the Template tab is automatically selected, and it also receives browser focus (this confirms that we're addressing the race condition described above)

Testing Instructions for Keyboard

  1. Launch the site editor
  2. Press [Tab] until focus is applied to the currently active tab in the sidebar
  3. Confirm arrow keys move you focus between tabs, but do not automatically select the focused tab
  4. Confirm the [Tab] key leaves the tablist and focuses the next element instead (the close button)
  5. Confirm that hitting [Tab] once more takes you to the first focusable element in the sidebar contents (specifically, you're making sure it doesn't focus the sidebar panel itself)

Copy link

github-actions bot commented Dec 11, 2023

Size Change: -251 B (0%)

Total Size: 1.69 MB

Filename Size Change
build/edit-site/index.min.js 195 kB +151 B (0%)
build/edit-site/style-rtl.css 15.1 kB -201 B (-1%)
build/edit-site/style.css 15.1 kB -201 B (-1%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 955 B
build/annotations/index.min.js 2.69 kB
build/api-fetch/index.min.js 2.32 kB
build/autop/index.min.js 2.1 kB
build/blob/index.min.js 578 B
build/block-directory/index.min.js 7.22 kB
build/block-directory/style-rtl.css 1.02 kB
build/block-directory/style.css 1.02 kB
build/block-editor/content-rtl.css 4.35 kB
build/block-editor/content.css 4.35 kB
build/block-editor/default-editor-styles-rtl.css 381 B
build/block-editor/default-editor-styles.css 381 B
build/block-editor/index.min.js 250 kB
build/block-editor/style-rtl.css 15.5 kB
build/block-editor/style.css 15.5 kB
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 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/block/editor-rtl.css 305 B
build/block-library/blocks/block/editor.css 305 B
build/block-library/blocks/button/editor-rtl.css 415 B
build/block-library/blocks/button/editor.css 414 B
build/block-library/blocks/button/style-rtl.css 627 B
build/block-library/blocks/button/style.css 626 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 113 B
build/block-library/blocks/categories/editor.css 112 B
build/block-library/blocks/categories/style-rtl.css 124 B
build/block-library/blocks/categories/style.css 124 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 421 B
build/block-library/blocks/columns/style.css 421 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/comment-template/style-rtl.css 199 B
build/block-library/blocks/comment-template/style.css 198 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 647 B
build/block-library/blocks/cover/editor.css 650 B
build/block-library/blocks/cover/style-rtl.css 1.69 kB
build/block-library/blocks/cover/style.css 1.68 kB
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 98 B
build/block-library/blocks/details/style.css 98 B
build/block-library/blocks/embed/editor-rtl.css 322 B
build/block-library/blocks/embed/editor.css 322 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 316 B
build/block-library/blocks/file/editor.css 316 B
build/block-library/blocks/file/style-rtl.css 280 B
build/block-library/blocks/file/style.css 281 B
build/block-library/blocks/file/view.min.js 316 B
build/block-library/blocks/footnotes/style-rtl.css 201 B
build/block-library/blocks/footnotes/style.css 199 B
build/block-library/blocks/form-input/editor-rtl.css 227 B
build/block-library/blocks/form-input/editor.css 227 B
build/block-library/blocks/form-input/style-rtl.css 343 B
build/block-library/blocks/form-input/style.css 343 B
build/block-library/blocks/form-submission-notification/editor-rtl.css 340 B
build/block-library/blocks/form-submission-notification/editor.css 340 B
build/block-library/blocks/form-submit-button/style-rtl.css 69 B
build/block-library/blocks/form-submit-button/style.css 69 B
build/block-library/blocks/form/view.min.js 471 B
build/block-library/blocks/freeform/editor-rtl.css 2.61 kB
build/block-library/blocks/freeform/editor.css 2.61 kB
build/block-library/blocks/gallery/editor-rtl.css 947 B
build/block-library/blocks/gallery/editor.css 952 B
build/block-library/blocks/gallery/style-rtl.css 1.72 kB
build/block-library/blocks/gallery/style.css 1.72 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 654 B
build/block-library/blocks/group/editor.css 654 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 189 B
build/block-library/blocks/heading/style.css 189 B
build/block-library/blocks/html/editor-rtl.css 336 B
build/block-library/blocks/html/editor.css 337 B
build/block-library/blocks/image/editor-rtl.css 863 B
build/block-library/blocks/image/editor.css 862 B
build/block-library/blocks/image/style-rtl.css 1.6 kB
build/block-library/blocks/image/style.css 1.59 kB
build/block-library/blocks/image/theme-rtl.css 126 B
build/block-library/blocks/image/theme.css 126 B
build/block-library/blocks/image/view.min.js 2.01 kB
build/block-library/blocks/latest-comments/style-rtl.css 357 B
build/block-library/blocks/latest-comments/style.css 357 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 478 B
build/block-library/blocks/latest-posts/style.css 478 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 505 B
build/block-library/blocks/media-text/style.css 503 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 668 B
build/block-library/blocks/navigation-link/editor.css 669 B
build/block-library/blocks/navigation-link/style-rtl.css 103 B
build/block-library/blocks/navigation-link/style.css 103 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.25 kB
build/block-library/blocks/navigation/editor.css 2.26 kB
build/block-library/blocks/navigation/style-rtl.css 2.24 kB
build/block-library/blocks/navigation/style.css 2.23 kB
build/block-library/blocks/navigation/view.min.js 1.1 kB
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 377 B
build/block-library/blocks/page-list/editor.css 377 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 235 B
build/block-library/blocks/paragraph/editor.css 235 B
build/block-library/blocks/paragraph/style-rtl.css 335 B
build/block-library/blocks/paragraph/style.css 335 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 508 B
build/block-library/blocks/post-comments-form/style.css 508 B
build/block-library/blocks/post-content/editor-rtl.css 74 B
build/block-library/blocks/post-content/editor.css 74 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 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 141 B
build/block-library/blocks/post-excerpt/style.css 141 B
build/block-library/blocks/post-featured-image/editor-rtl.css 666 B
build/block-library/blocks/post-featured-image/editor.css 662 B
build/block-library/blocks/post-featured-image/style-rtl.css 342 B
build/block-library/blocks/post-featured-image/style.css 342 B
build/block-library/blocks/post-navigation-link/style-rtl.css 215 B
build/block-library/blocks/post-navigation-link/style.css 214 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 409 B
build/block-library/blocks/post-template/style.css 408 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-time-to-read/style-rtl.css 69 B
build/block-library/blocks/post-time-to-read/style.css 69 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 125 B
build/block-library/blocks/preformatted/style.css 125 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 354 B
build/block-library/blocks/pullquote/style.css 354 B
build/block-library/blocks/pullquote/theme-rtl.css 168 B
build/block-library/blocks/pullquote/theme.css 168 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 288 B
build/block-library/blocks/query-pagination/style.css 284 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 486 B
build/block-library/blocks/query/editor.css 486 B
build/block-library/blocks/query/view.min.js 983 B
build/block-library/blocks/quote/style-rtl.css 237 B
build/block-library/blocks/quote/style.css 237 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 140 B
build/block-library/blocks/read-more/style.css 140 B
build/block-library/blocks/rss/editor-rtl.css 149 B
build/block-library/blocks/rss/editor.css 149 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 184 B
build/block-library/blocks/search/editor.css 184 B
build/block-library/blocks/search/style-rtl.css 614 B
build/block-library/blocks/search/style.css 614 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/search/view.min.js 471 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 229 B
build/block-library/blocks/separator/style.css 229 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 323 B
build/block-library/blocks/shortcode/editor.css 323 B
build/block-library/blocks/site-logo/editor-rtl.css 754 B
build/block-library/blocks/site-logo/editor.css 754 B
build/block-library/blocks/site-logo/style-rtl.css 204 B
build/block-library/blocks/site-logo/style.css 204 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 682 B
build/block-library/blocks/social-links/editor.css 681 B
build/block-library/blocks/social-links/style-rtl.css 1.49 kB
build/block-library/blocks/social-links/style.css 1.48 kB
build/block-library/blocks/spacer/editor-rtl.css 348 B
build/block-library/blocks/spacer/editor.css 348 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 395 B
build/block-library/blocks/table/editor.css 395 B
build/block-library/blocks/table/style-rtl.css 639 B
build/block-library/blocks/table/style.css 639 B
build/block-library/blocks/table/theme-rtl.css 146 B
build/block-library/blocks/table/theme.css 146 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 403 B
build/block-library/blocks/template-part/editor.css 403 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/term-description/style-rtl.css 111 B
build/block-library/blocks/term-description/style.css 111 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 99 B
build/block-library/blocks/verse/style.css 99 B
build/block-library/blocks/video/editor-rtl.css 552 B
build/block-library/blocks/video/editor.css 555 B
build/block-library/blocks/video/style-rtl.css 185 B
build/block-library/blocks/video/style.css 185 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 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.1 kB
build/block-library/common.css 1.1 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 12.3 kB
build/block-library/editor.css 12.3 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/index.min.js 215 kB
build/block-library/reset-rtl.css 472 B
build/block-library/reset.css 472 B
build/block-library/style-rtl.css 14.7 kB
build/block-library/style.css 14.7 kB
build/block-library/theme-rtl.css 688 B
build/block-library/theme.css 693 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/blocks/index.min.js 51.6 kB
build/commands/index.min.js 15.5 kB
build/commands/style-rtl.css 921 B
build/commands/style.css 918 B
build/components/index.min.js 226 kB
build/components/style-rtl.css 12 kB
build/components/style.css 12 kB
build/compose/index.min.js 12.6 kB
build/core-commands/index.min.js 2.71 kB
build/core-data/index.min.js 72.7 kB
build/customize-widgets/index.min.js 12.1 kB
build/customize-widgets/style-rtl.css 1.34 kB
build/customize-widgets/style.css 1.33 kB
build/data-controls/index.min.js 640 B
build/data/index.min.js 8.92 kB
build/date/index.min.js 17.9 kB
build/deprecated/index.min.js 451 B
build/dom-ready/index.min.js 324 B
build/dom/index.min.js 4.65 kB
build/edit-post/classic-rtl.css 544 B
build/edit-post/classic.css 545 B
build/edit-post/index.min.js 25.1 kB
build/edit-post/style-rtl.css 5.67 kB
build/edit-post/style.css 5.66 kB
build/edit-widgets/index.min.js 17.3 kB
build/edit-widgets/style-rtl.css 4.23 kB
build/edit-widgets/style.css 4.23 kB
build/editor/index.min.js 61.6 kB
build/editor/style-rtl.css 5.43 kB
build/editor/style.css 5.43 kB
build/element/index.min.js 4.83 kB
build/escape-html/index.min.js 537 B
build/format-library/index.min.js 7.85 kB
build/format-library/style-rtl.css 478 B
build/format-library/style.css 477 B
build/hooks/index.min.js 1.55 kB
build/html-entities/index.min.js 448 B
build/i18n/index.min.js 3.58 kB
build/interactivity/file.min.js 440 B
build/interactivity/image.min.js 2.15 kB
build/interactivity/index.min.js 12.8 kB
build/interactivity/navigation.min.js 1.23 kB
build/interactivity/query.min.js 758 B
build/interactivity/router.min.js 1.13 kB
build/interactivity/search.min.js 610 B
build/is-shallow-equal/index.min.js 527 B
build/keyboard-shortcuts/index.min.js 1.74 kB
build/keycodes/index.min.js 1.46 kB
build/list-reusable-blocks/index.min.js 2.11 kB
build/list-reusable-blocks/style-rtl.css 836 B
build/list-reusable-blocks/style.css 836 B
build/media-utils/index.min.js 2.9 kB
build/modules/importmap-polyfill.min.js 12.2 kB
build/notices/index.min.js 948 B
build/nux/index.min.js 2 kB
build/nux/style-rtl.css 735 B
build/nux/style.css 732 B
build/patterns/index.min.js 5.44 kB
build/patterns/style-rtl.css 540 B
build/patterns/style.css 539 B
build/plugins/index.min.js 1.8 kB
build/preferences-persistence/index.min.js 2.07 kB
build/preferences/index.min.js 2.81 kB
build/preferences/style-rtl.css 698 B
build/preferences/style.css 700 B
build/primitives/index.min.js 975 B
build/priority-queue/index.min.js 1.52 kB
build/private-apis/index.min.js 1 kB
build/react-i18n/index.min.js 623 B
build/react-refresh-entry/index.min.js 9.47 kB
build/react-refresh-runtime/index.min.js 6.78 kB
build/redux-routine/index.min.js 2.7 kB
build/reusable-blocks/index.min.js 2.72 kB
build/reusable-blocks/style-rtl.css 243 B
build/reusable-blocks/style.css 243 B
build/rich-text/index.min.js 10.4 kB
build/router/index.min.js 1.79 kB
build/server-side-render/index.min.js 1.95 kB
build/shortcode/index.min.js 1.39 kB
build/style-engine/index.min.js 2.07 kB
build/token-list/index.min.js 582 B
build/url/index.min.js 3.72 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 41.8 kB
build/vendors/react.min.js 4.02 kB
build/viewport/index.min.js 957 B
build/warning/index.min.js 249 B
build/widgets/index.min.js 7.21 kB
build/widgets/style-rtl.css 1.15 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.02 kB

compressed-size-action

Copy link

github-actions bot commented Dec 11, 2023

Flaky tests detected in 07f355d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7278433086
📝 Reported issues:

@chad1008 chad1008 force-pushed the tabs-site-editor-settings branch 2 times, most recently from 4e9165d to 530c9b1 Compare December 13, 2023 18:27
@chad1008 chad1008 requested a review from a team December 13, 2023 20:56
@chad1008 chad1008 self-assigned this Dec 13, 2023
@chad1008 chad1008 added the [Package] Components /packages/components label Dec 13, 2023
@chad1008 chad1008 marked this pull request as ready for review December 13, 2023 20:56
@chad1008 chad1008 added the [Type] Enhancement A suggestion for improvement. label Dec 13, 2023
@chad1008 chad1008 changed the title WIP: Implement Tabs in site-editor settings Implement Tabs in site-editor settings Dec 13, 2023
@afercia afercia added the Needs Accessibility Feedback Need input from accessibility label Dec 20, 2023
@afercia
Copy link
Contributor

afercia commented Dec 20, 2023

I see neither this PR or #55360 have the 'Accessibility' label or the 'Needs Accessibility feedback' label. It would be greatly appreciated that any change that is relevant for accessibility gets marked with those labels. Also, pinging some accessibility specialists for feedback would be appreciated.

I would also like to note that I don't see any related GitHub issue for this PR nor for #55360. The contributing guidelines for repository management of this project state that, quoting:

Non-trivial pull requests should be preceded by a related issue that defines the problem to solve and allows for discussion of the most appropriate solution before actually writing code.

Allowing broader discussion on important, impactful changes is essential in an open source project to make sure we deliver the best possible user experience. Also, I'm not sure not following the contributing guidelines is the best way to encourage collaboration between teams and contributors.

That said, @joedolson @alexstine @andrewhayward are we OK with changing the buttons to switch the settings panel to an ARIA tabs interface?

I would like to remind everyone that not using ARIA tabs here was a deliberate choice made a few years ago (in 2018). See for example here: #8079 (comment)

The point is that the main advantage of ARIA tabs is that they reduce the amount of tab stops to navigate the user interface with the keyboard. That makes perfectly sense when there are many tabs. Personally, I doubt it brings in any advantage when there's only two tabs. That's just my personal oopinion though and I'd like to hear some thoughts from other accessibility specialists.

To be clear: I do realize an ARIA tabs interface is 'more standard' but I still doubt it's a better user experience in this specific case.

In any case, if we go with an ARIA tabs interface, I'm not sure that in this specific case the activation of the panels should be automatic. There are two patterns: Automatic activation and Manual activation. I think manual activation would be more appropriate here.

Note that In the post editor these buttons have already been changed to ARIA tabs in #55360

@ciampo
Copy link
Contributor

ciampo commented Dec 20, 2023

Also, pinging some accessibility specialists for feedback would be appreciated.

@andrewhayward is an accessibility specialist and was indeed pinged on this issue (and other related ones), although we're more than happy to ping a wider group in the future.

I would also like to note that I don't see any related GitHub issue for this PR nor for #55360. The contributing guidelines for repository management of this project state that, quoting:

Non-trivial pull requests should be preceded by a related issue that defines the problem to solve and allows for discussion of the most appropriate solution before actually writing code.

There is a tracking issue related to the Tabs component and its related reactors #52997

I do realize an ARIA tabs interface is 'more standard' but I still doubt it's a better user experience in this specific case.

Related to whether it's a good idea to use aria tabs, my personal opinion is it's better to provides a more standard, predictable experience across the editor. As a user, it's very confusing that separate tabs-like interfaces behave differently.

Note that In the post editor these buttons have already been changed to ARIA tabs in #55360

Using the same component also allows us to reduce code repetition across many places in the editor, resulting in smaller bundle sizes, less code maintenance, and fewer bugs.

In any case, if we go with an ARIA tabs interface, I'm not sure that in this specific case the activation of the panels should be automatic. There are two patterns: Automatic activation and Manual activation. I think manual activation would be more appropriate here.

I'll let folks discuss and agree on the best decision here — in any case, that specific behaviour can be controlled via the selectOnMove prop on the Tabs component.

@alexstine
Copy link
Contributor

I think it's fine to use the ARIA tabs pattern, it adds consistency even if it is only a couple tabs. I've wanted this UI change for a while now and very happy with the results. I think it's also fine to change tabs based on automatic selection alone. The only area I'd ever push back on that is if focus is moved. If focus moves on tab selection, it must use manual activation.

Thanks.

@joedolson
Copy link
Contributor

On the whole, I think we should probably bias towards a consistent interface. While this is indeed not a scenario as is where the tab interface offers a lot of benefit, if we are using tabs in other, similar interfaces, then it's beneficial for those interfaces to behave the same way. That creates a lower cognitive burden for users, since they can operate patterns the same way when they occur.

Though the exception may offer a minor benefit in this particular situation, I'm not sure that specific use-case benefit should outweigh consistency in UX.

Regarding automatic vs. manual activation: I prefer manual activation, but would be OK with automatic activation. Automatic activation is just a bit less predictable.

@chad1008
Copy link
Contributor Author

@afercia, thanks for the feedback on the Accessibility labels, that's something I can pay more attention to in the future.

@alexstine and @joedolson thank you both also for jumping in with your thoughts. It sounds like the most undecided point is auto vs manual selection. I took another look at the guidelines:

It is recommended that tabs activate automatically when they receive focus as long as their associated tab panels are displayed without noticeable latency.

Because latency when displaying the tab contents isn't really a concern here, and we aren't facing unexpected focus changes like the ones Alex mentioned, I'm inclined to lean towards auto activation. Does anyone have a strong objection to that approach?

@afercia
Copy link
Contributor

afercia commented Dec 21, 2023

Because latency when displaying the tab contents isn't really a concern here, and we aren't facing unexpected focus changes like the ones Alex mentioned, I'm inclined to lean towards auto activation.

My only concern is that the Tags, Categories, Featured image panels render with some delay on first render but that would happen also with manual activation. Generally, I'd prefer manual activation. Regardless, I'd think the most important thing is to establish a pattern to be used across the editor. Having some tabs that work with manual activation and other tabs that work with auto activation isn't probably the best user experience. I'd prefer they all either use manual or auto activation, everywhere in the UI.

I would also like to note that I don't see any related GitHub issue for this PR nor for #55360. The contributing guidelines for repository management of this project state that, quoting:

Non-trivial pull requests should be preceded by a related issue that defines the problem to solve and allows for discussion of the most appropriate solution before actually writing code.

There is a tracking issue related to the Tabs component and its related reactors #52997

@ciampo I'm not sure that's relevant. That issue is related to refactoring existing tabs interfaces with the new implementation. Instead, this PR introduces a new tabs interface where it was explicitly decided to not use it, This PR changes an important accessibility feature and changes decisione that were made previously. I'm perfectly fine with changes for a better user experience but such changes must be discussed broadly and following this project guidelines is the best way to do it. It's also a requirement for all contributors. Thanks.

@afercia
Copy link
Contributor

afercia commented Jan 10, 2024

Quick question: for consistency, Tabs should be implemented also in the Widgets Editor. Is there an issue for that already? Screenshot:

Screenshot 2024-01-10 at 11 50 20

@chad1008
Copy link
Contributor Author

Quick question: for consistency, Tabs should be implemented also in the Widgets Editor. Is there an issue for that already?

Good point @afercia! These button based tab-like patterns are easier to miss than the existing TabPanel implementations, so I appreciate you pointing this one out. I'll add it to the tracking issue.

@chad1008
Copy link
Contributor Author

Alternatively, we could add some explicit code in packages/edit-site/src/components/sidebar-edit-mode/index.js, maybe a useEffect that can react when the selectedTabId changes and that is able to move focus accordingly.

Sorry @ciampo, somehow I missed this comment until just now. That's an interesting idea. My biggest hesitation with it is that we'd need to implement matching behavior for similar sidebar patterns. Specifically those that were previously using the same list-of-Buttons pattern that the site editor setting did. At the moment that would be the post/page editor settings, and now the widget settings as well.

If I can put something that works well more universally into Tabs directly, I'd love to. I have a draft PR in the works as a proof of concept to gather feedback and input on 😄

@chad1008 chad1008 force-pushed the tabs-site-editor-settings branch 2 times, most recently from 42d6218 to 6aa6f3f Compare February 1, 2024 20:18
Copy link

github-actions bot commented Feb 1, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core SVN

If you're a Core Committer, use this list when committing to wordpress-develop in SVN:

Props: shireling, mciampini, andrewhayward, afercia, alexstine, joedolson.

GitHub Merge commits

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: chad1008 <shireling@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: andrewhayward <andrewhayward@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: alexstine <alexstine@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@chad1008
Copy link
Contributor Author

chad1008 commented Feb 1, 2024

Now that #57696 is merged, this PR should be ready for another round of review.

The updates to Tabs in that PR remove any browser focus handling by the component, which means that the site-editor sidebar is subject to a race condition when tabbing into the sidebar from the last block in the canvas. This PR now has a fix for that issue as well.

I've updated the PR description and testing instructions with the relevant details!

@chad1008 chad1008 requested a review from ciampo February 1, 2024 23:00
Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

For some reason I'm not able to select tabs with arrow keys — the selection always stays on the same tab.

The cause seems to be the changes introduced by #57696 — for some reason, the focusedElement's ID is not yet updated when the activeId from ariakit updates.

I managed to make this work by wrapping the contents of that hook inside a requestAnimationFrame, which seems to give the browser enough time to apply the change of focus

Click to show diff
diff --git a/packages/components/src/tabs/index.tsx b/packages/components/src/tabs/index.tsx
index e8e9bff76b..4573f7a696 100644
--- a/packages/components/src/tabs/index.tsx
+++ b/packages/components/src/tabs/index.tsx
@@ -164,23 +164,25 @@ function Tabs( {
 			return;
 		}
 
-		const focusedElement =
-			items?.[ 0 ]?.element?.ownerDocument.activeElement;
-
-		if (
-			! focusedElement ||
-			! items.some( ( item ) => focusedElement === item.element )
-		) {
-			return; // Return early if no tabs are focused.
-		}
+		requestAnimationFrame( () => {
+			const focusedElement =
+				items?.[ 0 ]?.element?.ownerDocument.activeElement;
+
+			if (
+				! focusedElement ||
+				! items.some( ( item ) => focusedElement === item.element )
+			) {
+				return; // Return early if no tabs are focused.
+			}
 
-		// If, after ariakit re-computes the active tab, that tab doesn't match
-		// the currently focused tab, then we force an update to ariakit to avoid
-		// any mismatches, especially when navigating to previous/next tab with
-		// arrow keys.
-		if ( activeId !== focusedElement.id ) {
-			setActiveId( focusedElement.id );
-		}
+			// If, after ariakit re-computes the active tab, that tab doesn't match
+			// the currently focused tab, then we force an update to ariakit to avoid
+			// any mismatches, especially when navigating to previous/next tab with
+			// arrow keys.
+			if ( activeId !== focusedElement.id ) {
+				setActiveId( focusedElement.id );
+			}
+		} );
 	}, [ activeId, isControlled, items, setActiveId ] );
 
 	const contextValue = useMemo(

Unless you can think of any other reasons why this implementation in the site editor does not like every other similar implementation (post editor, widgets), we should probably add that change in a separate PR and come back here after

@chad1008
Copy link
Contributor Author

chad1008 commented Feb 2, 2024

Thanks for spotting that regression @ciampo, I'm sorry I missed it.

I've opened #58625 to implement your suggestion and it does test well for me too.

@chad1008
Copy link
Contributor Author

chad1008 commented Feb 2, 2024

Feedback addressed! Thanks as always @ciampo

@chad1008 chad1008 requested a review from ciampo February 2, 2024 17:06
Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

🚀

@chad1008 chad1008 merged commit 15a5a88 into trunk Feb 2, 2024
58 checks passed
@chad1008 chad1008 deleted the tabs-site-editor-settings branch February 2, 2024 18:54
@github-actions github-actions bot added this to the Gutenberg 17.7 milestone Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Accessibility Feedback Need input from accessibility [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants