-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
DataViews: add labels to "in-filters" #56001
Conversation
Size Change: +1.64 kB (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
value={ activeValue } | ||
prefix={ | ||
<InputControlPrefixWrapper | ||
as="span" | ||
as="label" | ||
htmlFor={ id } | ||
className="dataviews__select-control-prefix" | ||
> | ||
{ filter.name + ':' } |
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.
Aside: Just saw this, I think we should either remove the :
or use sprint and __ here, not all locals support this notation I think. cc @oandregal
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 going to become "Author is" when the new component is ready.
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'll wait until this PR is merged to fix it – or if you'd rather do it yourself, @andrewhayward, you're welcome :)
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.
@oandregal I'll let you do that in a separate PR. Scope, etc!
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.
@@ -18,12 +19,16 @@ export default ( { filter, view, onChangeView } ) => { | |||
? '' | |||
: valueFound.value; | |||
|
|||
const id = useInstanceId( InFilter, 'dataviews__filters-in' ); |
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.
Nice, thanks. Could we use as id
something like dataviews__filters-in-author
instead of dataviews__fisters-in-0
?
We could take the field name from filter.field
(author
, status
) and they are unique. filter.name
is more of a user-facing name (can have spaces, etc.) so it wouldn't work that well I guess.
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 we use React's useId instead of useInstanceId? Feels like the latter should be deprecate these days.
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.
Happy to go with whatever works for the team. If we're confident that filter.field
is unique, and each filter type will only appear once on the page, then makes sense to use that – in which case, we won't need to apply either useInstanceId
or useId
.
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 left a suggestion for the id
, though any works for me – whatever you think makes more sense.
Flaky tests detected in 5041584. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6825227413
|
* Add labels to data views "in" filters All user inputs should have an accessible name, ideally provided by a visible label. This patch ensures that data views "in" filters semantically associate the visible label with the select input, ensuring that the input has an accessible name.
What?
This patch ensures that "in-filter" inputs have accessible names.
It is an alternative approach to that explored by #55977, tackling the issue closer to the problem. Given the likely short-term lifecycle of the filter implementation, this is more economical alternative to #55963.
Why?
All user inputs should have an accessible name. This is currently lacking in data view filters.
How?
The visible label is updated to use a
<label>
element, and semantically linked to the select input with afor
/id
combination.The alternative of setting
label
/hideLabelFromVision
props on the parent<SelectControl>
was considered, but this approach has the benefit of physically associating the label with the control as well as semantically, so clicking on it will focus the input.Testing Instructions
Nothing should visually change.
Using developer tools, a screen reader, or similar, confirm that the filter inputs have accessible names, derived from the visible labels.