Skip to content

DataViews: Name the table media when the title is hidden - #87233

Open
HrithikDalal wants to merge 1 commit into
WordPress:trunkfrom
HrithikDalal:fix/dataviews-table-media-focus
Open

HrithikDalal wants to merge 1 commit into
WordPress:trunkfrom
HrithikDalal:fix/dataviews-table-media-focus

Conversation

@HrithikDalal

@HrithikDalal HrithikDalal commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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?

  • The table row passes a mediaLabel (the formatted title value) when the title isn't shown. The media uses it, falling back to "Navigate to item".
  • With the title shown, the media is still named after the title, as on trunk.
  • The focus ring on the media this PR also added is on trunk now, from DataViews: Use the focus ring mixin for all focus rings #87691, so that part was dropped.

Testing Instructions

The title can't be hidden from View options in Pages or the stories, so it needs showTitle: false in a view.

  1. In packages/dataviews/src/dataviews/stories/layout-table.tsx, add showTitle: false to the initial view.
  2. npm run storybook:dev, open Design System > DataViews > DataViews > Layout Table.
  3. Tab to a thumbnail. It's named after the item's title. On trunk it has no name.

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.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

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: HrithikDalal <hrithikd@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: oandregal <oandregal@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.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@HrithikDalal
HrithikDalal force-pushed the fix/dataviews-table-media-focus branch from 0719215 to 9b536f2 Compare November 23, 2026 06:47
@ntsekouras ntsekouras added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). labels Nov 23, 2026
? titleField.getValue?.( { item } )
: undefined
}
{ ...( isMediaRedundant && {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

  1. pass the label from the table, like mediaAspectRatio:
mediaLabel={
        showTitle
                ? undefined
                : titleField?.getValueFormatted( { item, field: titleField } )
}
  1. here:
const isMediaClickable =
        isItemClickable( item ) && ( !! onClickItem || !! renderItemLink );
const isMediaRedundant = isMediaClickable && !! titleField;
...
{ ...( isMediaClickable &&
        ! titleField && {
                'aria-label': mediaLabel || __( 'Navigate to item' ),
        } ) }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, same as the grid: the title value, falling back to "Navigate to item".

@oandregal

Copy link
Copy Markdown
Member

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.mov

With this PR it is not (unless title is hidden):

Screen.Recording.2026-11-25.at.12.46.04.mov

@HrithikDalal
HrithikDalal force-pushed the fix/dataviews-table-media-focus branch from 9b536f2 to 1618f51 Compare November 27, 2026 09:04
@HrithikDalal HrithikDalal changed the title DataViews: Show a focus ring on the table media and keep it out of the tab order next to a clickable title DataViews: Show a focus ring on the table media and name it when the title is hidden Nov 27, 2026
@HrithikDalal

Copy link
Copy Markdown
Contributor Author

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.

@ntsekouras

Copy link
Copy Markdown
Contributor

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.

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

@HrithikDalal

Copy link
Copy Markdown
Contributor Author

Happy to go either way here. Will wait for Joe's take before changing it back.

@joedolson

Copy link
Copy Markdown
Contributor

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:

  1. Both items are focusable; have a visible focus, and if they have the same function, have the same label.
  2. Both items are focusable, they have a visible focus, and if they have different functions, have different labels conveying their different behaviors.

...but...

  1. If both behaviors are the same, as in (1), then this is functionally a duplicate control in neighboring positions. There is no value to a keyboard user to be able to focus both controls, and there is no benefit to a screen reader user to have both controls announced. In that case, it is better to either combine both items into a single control or omit one of the two from keyboard sequences. I would generally prefer to combine the two into a single control, but omitting one is still an improvement, as it avoids an unnecessary tab stop and announcement.

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.

@HrithikDalal

Copy link
Copy Markdown
Contributor Author

@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:

  1. Bring back the skip: with the title shown, the image is left out of the tab order and hidden from screen readers. The focus ring and the label when the title is hidden stay.
  2. Combine the image and title into one control, which Joe prefers. That's a bigger change to the primary column, so I'd do it separately.
  3. Keep it as it is.

I'd go with 1 here and 2 as a follow-up, but happy to go with what you think works best.

@ntsekouras

Copy link
Copy Markdown
Contributor

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.

@HrithikDalal
HrithikDalal force-pushed the fix/dataviews-table-media-focus branch from 1618f51 to a6029e7 Compare December 3, 2026 04:47
Copilot AI balanced review requested due to automatic review settings December 3, 2026 04:47
@HrithikDalal HrithikDalal changed the title DataViews: Show a focus ring on the table media and name it when the title is hidden DataViews: Name the table media when the title is hidden Dec 3, 2026
@HrithikDalal

Copy link
Copy Markdown
Contributor Author

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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

@HrithikDalal
HrithikDalal force-pushed the fix/dataviews-table-media-focus branch from a6029e7 to 7530492 Compare December 3, 2026 16:23

This branch has not been deployed

No deployments
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). [Package] DataViews /packages/dataviews [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants