-
Notifications
You must be signed in to change notification settings - Fork 4.6k
DataViewsPicker Grid layout: Support hiding the title #71865
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -89,6 +89,11 @@ function GridItem< Item >( { | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||
| <Composite.Item | ||||||||||||||||||||||||||||||
| aria-label={ | ||||||||||||||||||||||||||||||
| titleField | ||||||||||||||||||||||||||||||
| ? titleField.getValue( { item } ) || __( '(no title)' ) | ||||||||||||||||||||||||||||||
| : undefined | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| key={ id } | ||||||||||||||||||||||||||||||
| render={ ( { children, ...props } ) => ( | ||||||||||||||||||||||||||||||
| <VStack spacing={ 0 } children={ children } { ...props } /> | ||||||||||||||||||||||||||||||
|
|
@@ -130,14 +135,16 @@ function GridItem< Item >( { | |||||||||||||||||||||||||||||
| tabIndex={ -1 } | ||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||
| ) } | ||||||||||||||||||||||||||||||
| <HStack | ||||||||||||||||||||||||||||||
| justify="space-between" | ||||||||||||||||||||||||||||||
| className="dataviews-view-picker-grid__title-actions" | ||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||
| <div className="dataviews-view-picker-grid__title-field dataviews-title-field"> | ||||||||||||||||||||||||||||||
| { renderedTitleField } | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| </HStack> | ||||||||||||||||||||||||||||||
| { showTitle && ( | ||||||||||||||||||||||||||||||
| <HStack | ||||||||||||||||||||||||||||||
| justify="space-between" | ||||||||||||||||||||||||||||||
| className="dataviews-view-picker-grid__title-actions" | ||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||
| <div className="dataviews-view-picker-grid__title-field dataviews-title-field"> | ||||||||||||||||||||||||||||||
| { renderedTitleField } | ||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I approved too quickly. A problem is that the items are all now unlabelled when using a screenreader if the visible label is hidden.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we handling that in the original grid view? If not it might be worth fixing for both?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the checkbox gets a proper label, but the click wrapper around the image is missing a label. I think this is the relevant code: gutenberg/packages/dataviews/src/dataviews-layouts/grid/index.tsx Lines 117 to 130 in 9f20f50
Having said that, in the story the image click wrappers are missing labels even when there's a visible title, so not sure what's going on there. I guess that code is a bit buggy.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for flagging! I think the picker might want a slightly different approach to the standard Grid... a natural place for the label to go in the picker could be to add an
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in de85bbf, seems to be working pretty well in my testing using macOS voiceover 👍 |
||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| </HStack> | ||||||||||||||||||||||||||||||
| ) } | ||||||||||||||||||||||||||||||
| <VStack spacing={ 1 }> | ||||||||||||||||||||||||||||||
| { showDescription && descriptionField?.render && ( | ||||||||||||||||||||||||||||||
| <descriptionField.render | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
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.
Just explaining the use of a ternary here and falling back to
undefined. For usage where atitleFielditself is not provided, falling back toundefinedwill allow voice over to read from text within the component.For example, if someone uses the DataViews and does not provide a title field, but does provide a description field, then the description field will be read out.
So the approach here uses a best-effort to provide a title as the label if a title field is set, otherwise it defers to the screen reader utility to make do with what's available.