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

Show text labels in block toolbars when option is set. #26135

Merged
merged 23 commits into from
Jan 18, 2021

Conversation

tellthemachines
Copy link
Contributor

Description

Follows on from #24304 and addresses most of remaining work for #15311 .

How has this been tested?

Tested across browsers.

Screenshots

Top toolbars are working on large and small breakpoints (small with horizontal scrollbar)

Screen Shot 2020-10-15 at 1 51 15 pm

Screen Shot 2020-10-15 at 1 52 39 pm

Inline toolbar gets a bit long, not sure how we can improve it:

Screen Shot 2020-10-15 at 1 52 08 pm

Types of changes

New feature (non-breaking change which adds functionality)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@tellthemachines tellthemachines added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Needs Design Feedback Needs general design feedback. Needs Accessibility Feedback Need input from accessibility [a11y] Labelling labels Oct 15, 2020
@tellthemachines tellthemachines self-assigned this Oct 15, 2020
@tellthemachines tellthemachines requested a review from mapk October 15, 2020 03:02
@github-actions
Copy link

github-actions bot commented Oct 15, 2020

Size Change: +497 B (0%)

Total Size: 1.28 MB

Filename Size Change
build/a11y/index.js 1.14 kB -1 B (0%)
build/annotations/index.js 3.8 kB -3 B (0%)
build/autop/index.js 2.83 kB +1 B (0%)
build/block-directory/index.js 9.03 kB -2 B (0%)
build/block-editor/index.js 121 kB +66 B (0%)
build/block-editor/style-rtl.css 11.8 kB +124 B (+1%)
build/block-editor/style.css 11.8 kB +121 B (+1%)
build/block-library/blocks/cover/editor-rtl.css 524 B +16 B (+3%)
build/block-library/blocks/cover/editor.css 522 B +16 B (+3%)
build/block-library/blocks/cover/style-rtl.css 1.3 kB -22 B (-2%)
build/block-library/blocks/cover/style.css 1.3 kB -21 B (-2%)
build/block-library/editor-rtl.css 8.94 kB +6 B (0%)
build/block-library/editor.css 8.94 kB +6 B (0%)
build/block-library/index.js 142 kB +385 B (0%)
build/block-library/style-rtl.css 8.5 kB -23 B (0%)
build/block-library/style.css 8.5 kB -19 B (0%)
build/blocks/index.js 48.1 kB -5 B (0%)
build/components/index.js 173 kB +68 B (0%)
build/compose/index.js 11.2 kB +1 B (0%)
build/core-data/index.js 15.2 kB +20 B (0%)
build/data/index.js 8.97 kB +2 B (0%)
build/date/index.js 31.8 kB +2 B (0%)
build/deprecated/index.js 769 B +1 B (0%)
build/dom/index.js 4.95 kB -1 B (0%)
build/edit-navigation/index.js 11.1 kB +3 B (0%)
build/edit-post/index.js 306 kB -6 B (0%)
build/edit-post/style-rtl.css 6.52 kB -123 B (-2%)
build/edit-post/style.css 6.5 kB -122 B (-2%)
build/edit-site/index.js 24.2 kB +193 B (+1%)
build/edit-site/style-rtl.css 4 kB -43 B (-1%)
build/edit-site/style.css 4 kB -40 B (-1%)
build/edit-widgets/index.js 23.6 kB -2 B (0%)
build/edit-widgets/style-rtl.css 3.16 kB -58 B (-2%)
build/edit-widgets/style.css 3.16 kB -57 B (-2%)
build/editor/index.js 42.3 kB -4 B (0%)
build/element/index.js 4.62 kB -1 B (0%)
build/format-library/index.js 6.75 kB +4 B (0%)
build/i18n/index.js 3.57 kB -1 B (0%)
build/is-shallow-equal/index.js 697 B -1 B (0%)
build/notices/index.js 1.85 kB -2 B (0%)
build/nux/index.js 3.42 kB -2 B (0%)
build/plugins/index.js 2.54 kB +1 B (0%)
build/priority-queue/index.js 790 B +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.5 kB +19 B (0%)
build/shortcode/index.js 1.7 kB +1 B (0%)
build/warning/index.js 1.14 kB -1 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/api-fetch/index.js 3.42 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 196 B 0 B
build/block-library/blocks/archives/editor.css 196 B 0 B
build/block-library/blocks/audio/editor-rtl.css 194 B 0 B
build/block-library/blocks/audio/editor.css 194 B 0 B
build/block-library/blocks/audio/style-rtl.css 225 B 0 B
build/block-library/blocks/audio/style.css 225 B 0 B
build/block-library/blocks/block/editor-rtl.css 283 B 0 B
build/block-library/blocks/block/editor.css 283 B 0 B
build/block-library/blocks/button/editor-rtl.css 576 B 0 B
build/block-library/blocks/button/editor.css 577 B 0 B
build/block-library/blocks/button/style-rtl.css 552 B 0 B
build/block-library/blocks/button/style.css 552 B 0 B
build/block-library/blocks/buttons/editor-rtl.css 345 B 0 B
build/block-library/blocks/buttons/editor.css 346 B 0 B
build/block-library/blocks/buttons/style-rtl.css 419 B 0 B
build/block-library/blocks/buttons/style.css 419 B 0 B
build/block-library/blocks/calendar/style-rtl.css 319 B 0 B
build/block-library/blocks/calendar/style.css 319 B 0 B
build/block-library/blocks/categories/editor-rtl.css 210 B 0 B
build/block-library/blocks/categories/editor.css 209 B 0 B
build/block-library/blocks/categories/style-rtl.css 208 B 0 B
build/block-library/blocks/categories/style.css 208 B 0 B
build/block-library/blocks/code/style-rtl.css 216 B 0 B
build/block-library/blocks/code/style.css 216 B 0 B
build/block-library/blocks/columns/editor-rtl.css 300 B 0 B
build/block-library/blocks/columns/editor.css 299 B 0 B
build/block-library/blocks/columns/style-rtl.css 529 B 0 B
build/block-library/blocks/columns/style.css 528 B 0 B
build/block-library/blocks/embed/editor-rtl.css 594 B 0 B
build/block-library/blocks/embed/editor.css 595 B 0 B
build/block-library/blocks/embed/style-rtl.css 489 B 0 B
build/block-library/blocks/embed/style.css 489 B 0 B
build/block-library/blocks/file/editor-rtl.css 314 B 0 B
build/block-library/blocks/file/editor.css 313 B 0 B
build/block-library/blocks/file/style-rtl.css 352 B 0 B
build/block-library/blocks/file/style.css 352 B 0 B
build/block-library/blocks/freeform/editor-rtl.css 2.55 kB 0 B
build/block-library/blocks/freeform/editor.css 2.55 kB 0 B
build/block-library/blocks/gallery/editor-rtl.css 749 B 0 B
build/block-library/blocks/gallery/editor.css 750 B 0 B
build/block-library/blocks/gallery/style-rtl.css 1.17 kB 0 B
build/block-library/blocks/gallery/style.css 1.17 kB 0 B
build/block-library/blocks/group/editor-rtl.css 433 B 0 B
build/block-library/blocks/group/editor.css 432 B 0 B
build/block-library/blocks/group/style-rtl.css 190 B 0 B
build/block-library/blocks/group/style.css 190 B 0 B
build/block-library/blocks/heading/editor-rtl.css 248 B 0 B
build/block-library/blocks/heading/editor.css 248 B 0 B
build/block-library/blocks/heading/style-rtl.css 212 B 0 B
build/block-library/blocks/heading/style.css 212 B 0 B
build/block-library/blocks/html/editor-rtl.css 384 B 0 B
build/block-library/blocks/html/editor.css 385 B 0 B
build/block-library/blocks/image/editor-rtl.css 801 B 0 B
build/block-library/blocks/image/editor.css 800 B 0 B
build/block-library/blocks/image/style-rtl.css 569 B 0 B
build/block-library/blocks/image/style.css 570 B 0 B
build/block-library/blocks/latest-comments/editor-rtl.css 277 B 0 B
build/block-library/blocks/latest-comments/editor.css 275 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 382 B 0 B
build/block-library/blocks/latest-comments/style.css 382 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 254 B 0 B
build/block-library/blocks/latest-posts/editor.css 254 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 634 B 0 B
build/block-library/blocks/latest-posts/style.css 634 B 0 B
build/block-library/blocks/list/editor-rtl.css 203 B 0 B
build/block-library/blocks/list/editor.css 203 B 0 B
build/block-library/blocks/list/style-rtl.css 201 B 0 B
build/block-library/blocks/list/style.css 201 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 311 B 0 B
build/block-library/blocks/media-text/editor.css 311 B 0 B
build/block-library/blocks/media-text/style-rtl.css 642 B 0 B
build/block-library/blocks/media-text/style.css 640 B 0 B
build/block-library/blocks/more/editor-rtl.css 545 B 0 B
build/block-library/blocks/more/editor.css 545 B 0 B
build/block-library/blocks/navigation-link/editor-rtl.css 503 B 0 B
build/block-library/blocks/navigation-link/editor.css 504 B 0 B
build/block-library/blocks/navigation-link/style-rtl.css 805 B 0 B
build/block-library/blocks/navigation-link/style.css 803 B 0 B
build/block-library/blocks/navigation/editor-rtl.css 1.38 kB 0 B
build/block-library/blocks/navigation/editor.css 1.38 kB 0 B
build/block-library/blocks/navigation/style-rtl.css 274 B 0 B
build/block-library/blocks/navigation/style.css 274 B 0 B
build/block-library/blocks/nextpage/editor-rtl.css 507 B 0 B
build/block-library/blocks/nextpage/editor.css 507 B 0 B
build/block-library/blocks/paragraph/editor-rtl.css 236 B 0 B
build/block-library/blocks/paragraph/editor.css 236 B 0 B
build/block-library/blocks/paragraph/style-rtl.css 351 B 0 B
build/block-library/blocks/paragraph/style.css 352 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 329 B 0 B
build/block-library/blocks/post-author/editor.css 329 B 0 B
build/block-library/blocks/post-author/style-rtl.css 303 B 0 B
build/block-library/blocks/post-author/style.css 303 B 0 B
build/block-library/blocks/post-comments-form/style-rtl.css 358 B 0 B
build/block-library/blocks/post-comments-form/style.css 358 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 262 B 0 B
build/block-library/blocks/post-content/editor.css 262 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 206 B 0 B
build/block-library/blocks/post-excerpt/editor.css 206 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 453 B 0 B
build/block-library/blocks/post-featured-image/editor.css 453 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 223 B 0 B
build/block-library/blocks/post-featured-image/style.css 223 B 0 B
build/block-library/blocks/preformatted/style-rtl.css 193 B 0 B
build/block-library/blocks/preformatted/style.css 193 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 304 B 0 B
build/block-library/blocks/pullquote/editor.css 304 B 0 B
build/block-library/blocks/pullquote/style-rtl.css 428 B 0 B
build/block-library/blocks/pullquote/style.css 428 B 0 B
build/block-library/blocks/query-loop/editor-rtl.css 217 B 0 B
build/block-library/blocks/query-loop/editor.css 216 B 0 B
build/block-library/blocks/query-loop/style-rtl.css 427 B 0 B
build/block-library/blocks/query-loop/style.css 429 B 0 B
build/block-library/blocks/query/editor-rtl.css 279 B 0 B
build/block-library/blocks/query/editor.css 279 B 0 B
build/block-library/blocks/quote/editor-rtl.css 195 B 0 B
build/block-library/blocks/quote/editor.css 195 B 0 B
build/block-library/blocks/quote/style-rtl.css 284 B 0 B
build/block-library/blocks/quote/style.css 285 B 0 B
build/block-library/blocks/rss/editor-rtl.css 307 B 0 B
build/block-library/blocks/rss/editor.css 309 B 0 B
build/block-library/blocks/rss/style-rtl.css 394 B 0 B
build/block-library/blocks/rss/style.css 393 B 0 B
build/block-library/blocks/search/editor-rtl.css 285 B 0 B
build/block-library/blocks/search/editor.css 285 B 0 B
build/block-library/blocks/search/style-rtl.css 454 B 0 B
build/block-library/blocks/search/style.css 456 B 0 B
build/block-library/blocks/separator/editor-rtl.css 229 B 0 B
build/block-library/blocks/separator/editor.css 229 B 0 B
build/block-library/blocks/separator/style-rtl.css 352 B 0 B
build/block-library/blocks/separator/style.css 352 B 0 B
build/block-library/blocks/shortcode/editor-rtl.css 603 B 0 B
build/block-library/blocks/shortcode/editor.css 603 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 321 B 0 B
build/block-library/blocks/site-logo/editor.css 321 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 238 B 0 B
build/block-library/blocks/site-logo/style.css 238 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 283 B 0 B
build/block-library/blocks/social-link/editor.css 283 B 0 B
build/block-library/blocks/social-links/editor-rtl.css 811 B 0 B
build/block-library/blocks/social-links/editor.css 810 B 0 B
build/block-library/blocks/social-links/style-rtl.css 1.44 kB 0 B
build/block-library/blocks/social-links/style.css 1.44 kB 0 B
build/block-library/blocks/spacer/editor-rtl.css 391 B 0 B
build/block-library/blocks/spacer/editor.css 391 B 0 B
build/block-library/blocks/spacer/style-rtl.css 184 B 0 B
build/block-library/blocks/spacer/style.css 184 B 0 B
build/block-library/blocks/subhead/editor-rtl.css 223 B 0 B
build/block-library/blocks/subhead/editor.css 223 B 0 B
build/block-library/blocks/subhead/style-rtl.css 210 B 0 B
build/block-library/blocks/subhead/style.css 210 B 0 B
build/block-library/blocks/table/editor-rtl.css 593 B 0 B
build/block-library/blocks/table/editor.css 593 B 0 B
build/block-library/blocks/table/style-rtl.css 501 B 0 B
build/block-library/blocks/table/style.css 501 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 237 B 0 B
build/block-library/blocks/tag-cloud/editor.css 235 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 221 B 0 B
build/block-library/blocks/tag-cloud/style.css 221 B 0 B
build/block-library/blocks/template-part/editor-rtl.css 714 B 0 B
build/block-library/blocks/template-part/editor.css 714 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 220 B 0 B
build/block-library/blocks/text-columns/editor.css 220 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 283 B 0 B
build/block-library/blocks/text-columns/style.css 283 B 0 B
build/block-library/blocks/verse/editor-rtl.css 194 B 0 B
build/block-library/blocks/verse/editor.css 194 B 0 B
build/block-library/blocks/verse/style-rtl.css 215 B 0 B
build/block-library/blocks/verse/style.css 215 B 0 B
build/block-library/blocks/video/editor-rtl.css 617 B 0 B
build/block-library/blocks/video/editor.css 617 B 0 B
build/block-library/blocks/video/style-rtl.css 303 B 0 B
build/block-library/blocks/video/style.css 304 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 860 B 0 B
build/block-library/theme.css 860 B 0 B
build/block-serialization-default-parser/index.js 1.88 kB 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/data-controls/index.js 829 B 0 B
build/dom-ready/index.js 571 B 0 B
build/edit-navigation/style-rtl.css 938 B 0 B
build/edit-navigation/style.css 944 B 0 B
build/editor/editor-styles-rtl.css 476 B 0 B
build/editor/editor-styles.css 478 B 0 B
build/editor/style-rtl.css 3.89 kB 0 B
build/editor/style.css 3.89 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/style-rtl.css 620 B 0 B
build/format-library/style.css 621 B 0 B
build/hooks/index.js 2.27 kB 0 B
build/html-entities/index.js 623 B 0 B
build/keyboard-shortcuts/index.js 2.54 kB 0 B
build/keycodes/index.js 1.94 kB 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/media-utils/index.js 5.31 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.43 kB 0 B
build/server-side-render/index.js 2.77 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 3.01 kB 0 B
build/viewport/index.js 1.85 kB 0 B
build/wordcount/index.js 1.22 kB 0 B

compressed-size-action

@mapk
Copy link
Contributor

mapk commented Oct 15, 2020

This looks super difficult! Thanks for taking it on, @tellthemachines! 🙏

Here's a quick mockup I put together to work toward in this PR.

  • I renamed a few items trying to condense them more.
  • I removed the "Change block type or style" in hopes that just using the block name would be sufficient.
  • I put all formatting options into a dropdown. With the text label option, the toolbar gets too long when Bold, Italic, and Link are surfaced on the top level.
  • I like the idea of stacking "move up" and "move down" so let's give it a whirl.

Paragraph toolbar 2

@ZebulanStanphill
Copy link
Member

@mapk

I removed the "Change block type or style" in hopes that just using the block name would be sufficient.

I think that kind of defeats the whole point of this text label setting. Perhaps "Transform block" would be a better short label?

@mapk
Copy link
Contributor

mapk commented Oct 22, 2020

Perhaps "Transform block" would be a better short label?

I thought about that, but I also felt the name of the block was equally important. I wonder if we'd want to work in a slight redesign in this mode. Something like this?

Paragraph toolbar 3

@ZebulanStanphill
Copy link
Member

It's important to remember that the labels will be read out by screen readers, and I'm not sure a button labeled "paragraph transform block" will make much sense to someone using a screen reader.

I think this goes back to an issue I've pointed out before, where the block toolbar's transform button is serving dual function as an indicator of the current block type. This is already questionable in my opinion when icons are used, but as can be seen here, it becomes a lot more prominent when the buttons use text labels.

I think the current block type label needs to be split apart from the transform button. Semantically, it must not be inside the <button>.

What if we showed the current block type label in a thin strip above all the block toolbar buttons? That would give us plenty of room to display the full block title (along with the icon), without taking away (horizontal) space from any actual toolbar buttons. If we did this on both text and icon modes, we could change the transform button to use a dedicated "transform" icon, since it would no longer be acting as the block indicator.

@etoledom
Copy link
Contributor

📳✅ Tested on mobile and everything seems to be working as expected

@etoledom etoledom removed their request for review December 8, 2020 16:39
@tellthemachines tellthemachines force-pushed the try/block-toolbar-labels branch from 96782c9 to 1fedc5f Compare January 5, 2021 04:39
@tellthemachines
Copy link
Contributor Author

I'm finally getting back to this, and reading through all the comments. Thanks everyone for the feedback so far!

It's important to remember that the labels will be read out by screen readers, and I'm not sure a button labeled "paragraph transform block" will make much sense to someone using a screen reader.

Good point, and having the block name here may not be very helpful to a screen reader user because, in order to get to the block toolbar, they have to select the block itself first, so will already have had the block name announced at that step. It might be more useful if they access the transform button from a form controls menu, but then it will only will show up if a particular block is selected, meaning the user will have interacted with the block just before invoking the menu.

The block name is important for sighted users though.

What if we showed the current block type label in a thin strip above all the block toolbar buttons?

Would this be only when the text labels are enabled, or with the icons too?

@ZebulanStanphill
Copy link
Member

@tellthemachines

What if we showed the current block type label in a thin strip above all the block toolbar buttons?

Would this be only when the text labels are enabled, or with the icons too?

I'd say enable it for both. I think there are already a lot of cases where it's really hard to tell what block you're editing based on the icon: Columns versus Column, Buttons versus Button, the Query and Query Loop blocks, and so on. And that's not even taking into account plugin-added blocks such as a plugin Columns block versus a core Columns block, and etc. The inspector should not be relied on for this info because it's supposed to be for secondary/uncommonly-used options, not primary info like the block title. Additionally, mobile users will not be able to have the inspector open all the time due to limited screen space, so ideally, we should make info like the block title clearly visible without having it open.

Additionally, if we displayed the block title on its own little strip, we could move the block icon there as well, and we could give the transform button a dedicated icon, which would be an accessibility improvement.

@tellthemachines
Copy link
Contributor Author

I removed the block name from the switcher button for now, and shortened some of the labels as per @mapk's suggestion:

Screen Shot 2021-01-06 at 3 47 06 pm

Screen Shot 2021-01-06 at 3 46 58 pm

I'm not sure where to place the block name though, considering that the parent block button pops up just above the toolbar, which would be its most natural location:

Screen Shot 2021-01-06 at 3 47 26 pm

As for moving the "Bold", "Italic" etc. into a "Formatting" dropdown, it won't be too straightforward because the same formatting toolbar is shared between the block toolbar and the little one that pops up in captions. It feels a bit weird to turn that one into a dropdown and hide all the options. Even for the block toolbar I'm not 100% sure about it, as those are pretty frequently used options.

@tellthemachines tellthemachines force-pushed the try/block-toolbar-labels branch from 8656189 to a46769d Compare January 13, 2021 00:21
@tellthemachines
Copy link
Contributor Author

I reverted changes to the alignment labels as I was running into an issue where passing toggleProps to ToolbarGroup was causing the whole toolbar keyboard navigation to fail. As I'm still not sure of the root cause of this, I'd rather address it as a separate issue. For now, I settled for using "Align text" and "Align block" to differentiate between them (Change vertical alignment is unchanged).

@jasmussen
Copy link
Contributor

this is how padding is set when the icons show: all buttons have 6px each side, except for the first and last which have 12px. Should I reduce these to 6px when text labels are visible?

I think there's some gnarly hacks going on here, which I hope to clean up when I get a chance to, as part of #24898. Specifically there's some child rules that aim to optically space icons, which might just mess with things on the text labels. Probably best to leave it alone for now.

I'd rather leave that for a separate PR

👍 👍

@tellthemachines
Copy link
Contributor Author

Ok peeps, this one's ready for a final review. Many thanks to @diegohaz for fixing the issue with the alignment labels ⭐

@draganescu
Copy link
Contributor

I found this little stuffed text (Edge browser):

edge-caption-text-fit

@tellthemachines
Copy link
Contributor Author

@draganescu I can't reproduce that locally:

Screen Shot 2021-01-15 at 9 29 38 am

That string was shortened here. Could it be an issue with your local files, or maybe aggressive browser caching?

Copy link
Contributor

@draganescu draganescu left a comment

Choose a reason for hiding this comment

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

The code looks great IMO and my testing found no issues whatsoever. I did not test if this affects the screen reader experience negatively.

@@ -104,12 +106,18 @@ export function Button( props, ref ) {
// the tooltip is not explicitly disabled.
false !== showTooltip ) );

const descriptionId = describedBy ? uniqueId() : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

This uniqueId will change on every render, which is unnecessary.

I think it should use the useInstanceId hook.

</VisuallyHidden>
) }
</>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

There's some places where we assume buttons only render a single "parent" element. In the block toolbar for instance.

So when you render two buttons in the block toolbar that have descriptions, the spacing is not evenly distributed. See #39605 (comment)

Is it possible to move the visually hidden text inside the "button" or "a" directly? Would that be valid HTML? Is there any other alternative?

Copy link
Member

Choose a reason for hiding this comment

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

It would probably be valid HTML, but that doesn't mean it would be valid a11y. Putting it inside the <button>/<a> would make the whole thing be considered part of the button label. I don't think that would be correct/desirable, but I could be mistaken.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, the description shouldn't be inside the element being described.

Potentially we could find another workaround by adding in actual button text as we did with the global inserter.

But the visually hidden elements are absolutely positioned; I wouldn't expect them to occupy any space at all in the canvas. Could that spacing be caused by some other issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could that spacing be caused by some other issue?

We have some styles targetting last-child and first-child CSS pseudo elements causing these issues. So these addition conflicts with these styles. I'm considering exploring changes to these styles but with no guarantee of success.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I see, the problem is not VisuallyHidden but the pseudo-element we use to render the text label. In that case, we could definitely explore a similar approach to the global inserter: render actual text in the button instead of the pseudo-element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). 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.