-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Cover: Fix placeholder color options keyboard accessibility #68662
Changes from all commits
95c1e9a
fc45108
373b0d8
187e867
a26c125
fcf3311
cbf0929
7599ff3
abfed4e
142a586
61e8228
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 |
---|---|---|
|
@@ -132,7 +132,7 @@ function ButtonsCircularOptionPicker( | |
); | ||
|
||
return ( | ||
<div { ...additionalProps } id={ baseId }> | ||
<div { ...additionalProps } role="group" id={ baseId }> | ||
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. Is it ok to have a 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. Yes it is OK. It should use the fallback label though, am I missing something? 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 will when used in
If it is OK, should we remove the equivalent check in 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. A 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. Got it — feel free to work on this improvement to 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's very minor, not sure it is worth it. |
||
<CircularOptionPickerContext.Provider value={ contextValue }> | ||
{ options } | ||
{ children } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Computes the common props for the CircularOptionPicker. | ||
*/ | ||
export function getComputeCircularOptionPickerCommonProps( | ||
asButtons?: boolean, | ||
loop?: boolean, | ||
ariaLabel?: string, | ||
ariaLabelledby?: string | ||
) { | ||
const metaProps = asButtons | ||
? { asButtons: true } | ||
: { asButtons: false, loop }; | ||
|
||
const labelProps = { | ||
'aria-labelledby': ariaLabelledby, | ||
'aria-label': ariaLabelledby | ||
? undefined | ||
: ariaLabel || __( 'Custom color picker' ), | ||
}; | ||
|
||
return { metaProps, labelProps }; | ||
} |
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.
Question — is it a good practice to add extra logic to labels priority?
What I mean is, should we remove the custom logic in
getComputeCircularOptionPickerCommonProps
that ignoresaria-label
ifaria-labelledby
is defined? From what I understand, it's already the default behaviour applied by browsers, which means thataria-label
would be automatically ignored ifaria-labelledby
is also defined.In that sense, it wouldn't make sense to document the behaviour either, since it's standard DOM and not a particular behaviour of this component.
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.
Yes, aria-labelledby overrides aria-label so that's what browsers already do when exposing information in the accessibility tree. I think the logic and documentation do add value because developers need to be educated. They may set both props and think
aria-label
does something, while it wouldn't do anything,Anyways, I would say it's unrelated to the scope of this PR and the previous implementation made sure only one of the two was in use anyways.
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 agree with the point that this behavior was already part of the component's logic.
In general, though, I'd prefer not to document standard DOM features. Given that these are web components, consumers should assume Web Standards and platform behavior as a pre-requisite unless specified otherwise. Otherwise, where do we draw the line between what need to be re-documented and what can be left implied?