-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Migrating StyleBook
to use updated Composite
implementation
#55344
Conversation
Size Change: +2.27 kB (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing well and LGTM 🚀 🚢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the ping! This code change is looking good. I noticed one tiny difference in testing via keyboard between trunk
and this PR:
In trunk
if you use the home / end keys, then the first / last items scroll entirely into view as the home / end keys take the user all the way to the beginning or end of the scrollable area:
2023-10-16.12.02.16.mp4
With this PR, it seems that it only scrolls enough for the item to be visible, not all the way to the very end of the area, so examples can be slightly cut off:
2023-10-16.12.01.19.mp4
Would it be worth tweaking some styling with scroll-padding-top
and/or scroll-padding-bottom
(if that'll play nicely with Composite
, that is) to ensure items are always fully visible in that case?
Good catch. Added some some scroll margins, seems to be working a bit better now. |
There's a small issue in the media tab, where audio and video blocks sort of remain in the tab order. This is in Filed an issue with them – maybe it'll get resolved at some point! Works fine in Firefox/Safari. |
Flaky tests detected in fea8b96. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6983067267
|
className={ className } | ||
aria-label={ label } | ||
role="grid" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rationale for changing the role to grid
? Does it make sense even if every row always contains only one cell?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The grid pattern can be used to group a set of interactive elements, such as links, buttons, or checkboxes. Since only one element in the entire grid is included in the tab sequence, grouping with a grid can dramatically reduce the number of tab stops on a page. 1
In theory it should make it clearer that the buttons (as rendered by Example
below) should be navigated with arrow keys rather than tab. Most screen readers will announce the number of rows too, which means users get told how many buttons are in the collection
Footnotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker for this PR, but — have you considered using CompositeRow
(and potentially CompositeGroup
) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did, but I didn't want to move this too far away from the original implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Not sure if we should wait for @andrewserong to take a final look too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the ping! And apologies for missing the other updates last week, thanks for the follow-up.
I'm still seeing the outline of the active item being cut off when navigating via cursor keys (but especially home and end keys). I think we might be able to resolve it by using the hard-coded value of 32px
for the scroll top / bottom, to match the value that overrides padding on the body
element. Just left a comment with a couple screengrabs.
Other than that, though, this is looking good to me, too!
What?
This PR updates
StyleBook
in@wordpress/edit-site
to use the updatedComposite
implementation from #54225, and adds additional semantic context around the example blocks.Why?
In #54225, an updated implementation of
Composite
was added to@wordpress/components
. As per #55224, all consumers ofComposite
need to migrate from the old version to the new version.How?
__unstableComposite
imports from@wordpress/components
Composite*
exports from@wordpress/components
Examples
/Example
withinStyleBook
to use updatedComposite
componentsComposite
to make UX clearer for assistive technology users.Testing Instructions
Navigate to the Style Book overview, by selecting "Styles" from the "Design" menu, then opening the Style Book. The style book frame should still render as one actionable button. Clicking this should take you to the main story book view.
The style book can also be accessed from the the styles sidebar header in the site editor.
Each item within the Style Book should present as an actionable button, which should open the relevant section in the styles sidebar.
Testing Instructions for Keyboard
With the main style book view open, the set of block examples should present as buttons within a grid. These should be navigable by tabbing to the grid, and using the arrow keys to move up and down.