티스토리 수익 글 보기
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
DataViews: Add grid keyboard navigation
#72997
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
Conversation
| }; | ||
| } | ||
|
|
||
| function GridItem< Item >( { |
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.
Functionality of this component has not be updated. I just moved it in this file.
|
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 If you’re merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project’s expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +1.07 kB (+0.04%) Total Size: 2.54 MB
ℹ️ View Unchanged
|
Listbox is more semantic for the picker component because it’s specifically meant for lists that can be selected from, and also it may have better screen reader support than grid. There was a whole discussion on the PR that implemented it, starting here 😅 I agree that the arrow key navigation using only left and right keys isn’t ideal for the visual grid though. This might be one of those issues where there’s no perfect solution. |
tellthemachines
left a comment
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 keyboard navigation works OK for me in testing! It’s a bit awkward when “group by” is enabled because you have to Tab to the next group, but pressing Tab when an item is selected takes you through the actions buttons in that item first 😅
I’m not sure there’s any way to improve that though. I’d be keen to hear if @afercia or @alexstine have any ideas because we didn’t have the group by option when the first PR was reviewed.
I noticed in testing the Pages screen in site editor with VoiceOver that the title of each page is being read out 3 times when you arrow into it. That must be because we’re using the title as aria-label for both the image button and the checkbox. Could we maybe use aria-hidden on the title button because it duplicates the image button in functionality? And remove it as a tab stop too.
VoiceOver is also reading out both the “row” role and the aria-label for each row, so it goes “row Row 2”. I was curious enough to boot up my old Windows machine and check it on Firefox+NVDA, which handles it better: it just reads out “row 1 column 1”. NVDA also only reads the title twice 😅
Other than that, the code changes LGTM.
packages/dataviews/src/dataviews-layouts/grid/preview-size-picker.tsx
Outdated
Show resolved
Hide resolved
That’s weird because I have tested only with VoiceOver and as you can see in the video of the description, it says |
3bb0e36 to
35daba0
Compare
t-hamano
left a comment
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.
Tested on Windows OS with NVDA.
My screen reader reads out all the content inside the grid items, and I’m not sure if this is acceptable for accessibility, but I find it very annoying:
a70168bdb13ecffe11741c1bed1f32fc.mp4
Is it possible to apply explicit aria-label? For example, in the Notes feature, we recently applied explicit aria-labels to treeitem:
I would like to be able to use the title field for the aria-label, but I don’t think the titleField is a required field. Any ideas?
35daba0 to
e42fd37
Compare
Maybe use the title as an aria-label when it exists, else don’t add an aria-label. That way it’s up to consumers. It’s probably best practice to always have a title, even if it’s not shown visibly. I seem to recall it’s also still used for aria-labels when not visible. @andrewserong might know more specifics, as he did some past work on titles for grid. |
I’ve been researching for a while how (and if we should) remove some nested aria-labels to prevent them being announced when focusing the
I tried that with I’ve asked again for a review in core a11y channel and hopefully we get some more feedback. |
2002019 to
3f527f1
Compare
packages/dataviews/src/dataviews-layouts/grid/composite-grid.tsx
Outdated
Show resolved
Hide resolved
By the way I think that’s the expected behavior (to also announce the text inside the gridcell) for users to know what’s in there. |
6cc557c to
cf56146
Compare
It occurred to me that a similar approach to the List layout could be applied to the Grid layout. See: #59637
That is, use the |
cf56146 to
1cffe01
Compare
I explored this, but I’m not sure it’s the same use case.
This makes me wonder how |
t-hamano
left a comment
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.
Since this PR is a clear improvement, we think it’s okay to ship this PR for now.
As for aria-label, we can address it in a follow-up if necessary.
Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
1cffe01 to
325ffef
Compare
What?
This PR revives this old one: #68225 for adding keyboard navigation to DataViews
gridlayout. It applies the a11y feedback from the previous one, which seemed to be really close to landing.I opened a new one, because code had changed significantly in the past year.
Notes
Should we have similar navigation to
DataViewsPicker. Was there specific reasons for having alistboxeven if it displays a grid? –cc @talldan @tellthemachinesTesting Instructions
gridlayout should be displayed and work exactly as before. This means theautoadjusting of columns and thePreview sizeunder view options.Grouped byandInfinite scrollfunctionality should work well with the keyboard navigation.npm run storybook:devScreenshots or screencast
Screen.Recording.2025-11-05.at.11.48.03.AM.mov