-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Dataviews: make the media item clickable as well #70985
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
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. |
<ItemClickWrapper | ||
item={ item } | ||
isItemClickable={ isItemClickable } | ||
onClickItem={ onClickItem } | ||
renderItemLink={ renderItemLink } | ||
> |
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.
This ends up as a button without a label, so there's an a11y problem to solve.
For the title field the title itself is used as the label, so you could probably match that - perhaps using aria-labelledby
(https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby) and an id
on the title.
Another option is to make the whole thumbnail and title wrapped in the clickable - but it might not feel right from a user point of view.
TBH, I'm also not convinced the item title is descriptive enough as a label, it doesn't really tell a screenreader user what onClickItem
is going to do. Given dataviews is very abstract it could perform any kind of action. So another option is to add a way to pass a label in for an item, but that might be a separate story rather than trying to solve it in this PR. 😄
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.
Another option is to make the whole thumbnail and title wrapped in the clickable - but it might not feel right from a user point of view.
Yeah, this is something I've heard a few times, the fact that the "primary column" is clickable is not very discoverable. This would require some design thinking, perhaps exploring making the media+title+description a card? Though, it'd add some weight that we may not want. Pinging @jameskoster @matt-west in case they have thoughts.
It'd also be nice to group media/title/description in a single unit from a keyboard navigation point of view. Otherwise, there's a stop for the media and there's another stop for the title (but they trigger the same action).
TBH, I'm also not convinced the item title is descriptive enough as a label, it doesn't really tell a screenreader user what onClickItem is going to do. Given dataviews is very abstract it could perform any kind of action.
Perhaps we could do with a generic label such as "Click item" for now.
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'm not sure the description should be clickable. I think for now, adding the label (maybe a "Click Item %s"
) would be good enough.
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.
It seems easier for now to make the title and thumbnail separate clickable elements, assuming we can find a good label for the thumbnail. We might consider a hover effect too; maybe the thumbnail border darkens slightly...
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.
OK I went with Click item: <title>
I added a colon to avoid all the grammatical issues in non-English languages, considering the item is an object and whatnot.
onClickItem={ onClickItem } | ||
renderItemLink={ renderItemLink } | ||
> | ||
<div className="dataviews-view-table__cell-content-wrapper dataviews-column-primary__media"> |
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.
Is there a reason we need this extra div? Can we pass the className
to the ItemClickWrapper instead?
Thank you, everyone, for the reviews. I addressed all the feedback and rebased. |
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.
This is looking good to me. You might want to mention the change in the DataViews changelog.
onClickItem={ onClickItem } | ||
renderItemLink={ renderItemLink } | ||
className="dataviews-view-table__cell-content-wrapper dataviews-column-primary__media" | ||
title={ |
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.
Should this be title or aria-label?
packages/dataviews/CHANGELOG.md
Outdated
@@ -16,6 +16,10 @@ | |||
- Support Ctrl + Click / Cmd + Click for multiselecting rows in the Table layout ([#70891](https://github.com/WordPress/gutenberg/pull/70891)). | |||
- Add support for the `Edit` control on the date field type ([#70836](https://github.com/WordPress/gutenberg/pull/70836)). | |||
|
|||
### Enhancements | |||
|
|||
- Make the media item clickable along the title. |
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.
- Make the media item clickable along the title. | |
- Make the media item clickable along the title. [#70985](https://github.com/WordPress/gutenberg/pull/70985) |
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.
My bad, the pattern is so obvious.
What?
This makes the media field part of the primary column behave the same way the title does when clicked. This makes sense because it's part of the primary column anyway.
Why?
More intuitive experience.
How?
By wrapping the media field with the same
ItemClickWrapper
that wraps the title field.Testing Instructions
npm run storybook:dev
.Testing Instructions for Keyboard
Screenshots or screencast
Before
Screen.Recording.2025-07-30.at.16.53.24.mov
After
Screen.Recording.2025-07-30.at.16.51.27.mov