Repository navigation
DataViews: Name the table media when the title is hidden - #87233
HrithikDalal wants to merge 1 commit into
Conversation
🤖 PR meta 🤖🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the |
0719215 to
9b536f2
Compare
| ? titleField.getValue?.( { item } ) | ||
| : undefined | ||
| } | ||
| { ...( isMediaRedundant && { |
There was a problem hiding this comment.
I think we should we add an aria-label when the title is hidden, because in that case the media is the only clickable control and it has no accessible name.
Maybe do the same as the grid, use the title value and fall back to Navigate to item? It would look something like:
- pass the label from the table, like
mediaAspectRatio:
mediaLabel={
showTitle
? undefined
: titleField?.getValueFormatted( { item, field: titleField } )
}- here:
const isMediaClickable =
isItemClickable( item ) && ( !! onClickItem || !! renderItemLink );
const isMediaRedundant = isMediaClickable && !! titleField;
...
{ ...( isMediaClickable &&
! titleField && {
'aria-label': mediaLabel || __( 'Navigate to item' ),
} ) }There was a problem hiding this comment.
Done, same as the grid: the title value, falling back to "Navigate to item".
|
This PR skips the media item out of the tabbable items when there's a title: how is this an improvement? Note that the media item is still clickable. This is behaviour in trunk (the media item is always part of the sequence): Screen.Recording.2026-11-25.at.12.47.44.movWith this PR it is not (unless title is hidden): Screen.Recording.2026-11-25.at.12.46.04.mov |
9b536f2 to
1618f51
Compare
|
Fair point, reverted that. The media stays in the tab order like trunk, so this is now only the focus ring and the label when the title is hidden. |
The skip came from Joe's review(#82730 (comment)). He suggested combining the featured image and title into a single control and giving the image an empty name, because now the cell reads the title twice. The image is still clickable for mouse users, but keyboard users get the same action from the title next to it, so they don't miss anything. Should we bring it back? --cc @joedolson |
|
Happy to go either way here. Will wait for Joe's take before changing it back. |
|
Skipping an object in the tab order is fine, as long as the function and information is still available. From an accessibility perspective, this must be either:
...but...
There's no accessibility failure, because accessibility is about ensuring that the function can be performed equivalently; there's no need to have the actual control surface be identical. |
|
@ntsekouras Going by Joe's comment, what's here now is fine, but the image and the title end up as the same control twice. A few ways to go:
I'd go with 1 here and 2 as a follow-up, but happy to go with what you think works best. |
|
Thanks Joe for the feedback! I think combining them is a bigger change and I'm not sure it's worth it, if we're fine with skipping it like Joe suggests in option 3. Personally I'd bring back the skip, but I'd defer to @oandregal, since he had the concerns about that. |
1618f51 to
a6029e7
Compare
|
Rebased. The focus ring on the media landed on trunk with #87691, so I dropped that part and this is now only the label when the title is hidden. The tab order question is still open. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the thumbnail accessibility update.
No open issues 🎉
What changed in this PR
Improves DataViews table accessibility by naming clickable thumbnails when item titles are hidden, addressing part of #85052.
Changes:
- Uses the formatted item title as the thumbnail’s accessible name, with “Navigate to item” as a fallback.
- Adds regression tests and a changelog entry.
| File | Description |
|---|---|
| packages/dataviews/src/dataviews/test/dataviews.jsdom.test.tsx | Tests hidden-title and missing-title labels. |
| packages/dataviews/src/components/dataviews-layouts/table/index.tsx | Passes the formatted title as the media label. |
| packages/dataviews/src/components/dataviews-layouts/table/column-primary.tsx | Applies the accessible label and fallback. |
| packages/dataviews/CHANGELOG.md | Documents the accessibility fix. |
Review effort: Balanced
a6029e7 to
7530492
Compare
What?
Part of #85052
In the table layout, when the title isn't shown, clickable media is named after the item's title, or "Navigate to item" when there's no title field, like the grid layout.
Why?
With the title hidden, the thumbnail is the only control for the item and had no accessible name.
How?
mediaLabel(the formatted title value) when the title isn't shown. The media uses it, falling back to "Navigate to item".Testing Instructions
The title can't be hidden from View options in Pages or the stories, so it needs
showTitle: falsein a view.packages/dataviews/src/dataviews/stories/layout-table.tsx, addshowTitle: falseto the initial view.npm run storybook:dev, open Design System > DataViews > DataViews > Layout Table.Testing Instructions for Keyboard
Same as above with a screen reader on: the thumbnail is announced by the item's title.
Use of AI Tools
Used Claude Code to co-author the fix. Reviewed and tested by me.