Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
ColorPicker a11y fixes #1470
ColorPicker a11y fixes #1470
Changes from 11 commits
8f151a8
cbffb4e
00f21c3
4fc5acf
8449063
630a2a2
38654b3
4993641
f7d6feb
94f8b3a
9253248
db46b62
4dd6396
7119c9e
3de5c17
6a1fafb
ee5f503
9396da6
5600955
5c63f45
943fc15
4a481ac
9d32b88
31ddf48
7f7c197
9d44a26
9c0df13
74f0793
0f75854
f26b980
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
how did you decide on using
role=listbox
androle=option
?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 was the set of roles that was worked the best for the swatch array. Implementing a grid / gridcell system would have required too much refactoring. Meanwhile, giving the swatches the role of 'button' changes their appearance. 'Checkbox' didn't work for them either, because only one swatch is meant to be selected at a time.
'Listbox' / 'option' was the best structure I could find for a set of swatches. If there's another setup that you find works better, I can implement that instead.
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.
That makes sense, but previously there was no role, so I'm asking why/how you decided to add one. Which specific a11y violation is this addressing? Would have been nice if you made the PR description more... descriptive.
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 specifically addresses the
aria-input-fieldname
rule, which was violated in MainExample and AdvancedExample, because theSliders
needed an accessible 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.
this looks unrelated,
aria-input-field-name
is only violated for the sliders, whereas i'm asking about the changes in ColorPalette.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.
That's totally my bad. Lot of threads to keep track of!
The
listbox
andoption
roles were added to theColorPalette
and theColorSwatches
, respectively, because without those roles, it violated the 'aria-allowed-attribute' rule. This is because the Color Swatch component originally had thearia-selected
attribute, despite the component not being given a role.Other roles that can take
aria-selected
- Tab, Row, and Grid - either weren't appropriate forColorPalette
&ColorSwatch
, or (in the case of Grid) would have required a more extensive refactoring of the code than I figured would be necessary. (More info here.)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 have a default
aria-label
that theColorSwatch
adds? LikeswatchLabel
could be calculated insideColorSwatch
. If the user provided anaria-label
toColorSwatch
, we use it. But if not, we useswatchLabel
as thearia-label
.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'd like to implement this, although it might be a bit too involved of a refactor for the scope of this PR. I'll see what I can do.
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.
Actually, it is very small change, sorry if I didn't explain it clearly in my comment.
I meant like instead of calculating
swatchLabel
on L153, you can do it inColorSwatch.tsx
instead. Because you are passing the color toColorSwatch
on L159.Then in
ColorSwatch.tsx
, you can do something like this: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.
Ohh, actually
colorString
(L42-48 of the screenshot) already calculates the string representation of the color. You could try reusing that instead ofswatchLabel
.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.
colorString
return's the color's hex value, which wouldn't be very understandable. That's one of the main reasons I madeswatchLabel
its own thing - it returns the color's value in HSL form, which (in my experience) is easier to learn to interpret than the hex form.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.
Switched from hsl to hex
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.
please read the comment again, the suggestion is not to switch from hsl to hex, but to use
colorString
which preserves the source value (can be hex or hsl or whatever string the color was instantiated with)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 had tried using
colorString
for the swatch label already, but I couldn't figure out how to use it inColorPalette.tsx
. When I try usingcolorString
inColorSwatches.tsx
, its original scope,ColorPickerBasicExample
throws anaria-allowed-attribute
error for the selected color swatch on top.This is because that swatch doesn't have a role, since the roles are distributed in
ColorPalette.tsx
. I could try giving that swatch its own role in theexamples
file, but it's hard for me to tell what role is appropriate. I could also continue to assign the swatch labels the way I have been, even if it is redundant.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 be fixable if you use visually-hidden text instead of aria-label
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.
Done. It works!