-
Notifications
You must be signed in to change notification settings - Fork 198
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
fix: correct the display of checkbox read-only state #3328
Conversation
🦋 Changeset detectedLatest commit: dedd54c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🚀 Deployed on https://pr-3328--spectrum-css.netlify.app |
File metricsSummaryTotal size: 4.26 MB* Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.
Detailscheckbox
fieldgroup
* Results are not gzipped or minified. * An ASCII character in UTF-8 is 8 bits or 1 byte. |
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.
Love this- the read-only checkboxes are focusable, but cannot be checked/unchecked. 👍 I love that you added a bunch of the documentation from the guidelines site- thank you!
I did have a question about the expectations for what would be announced by a screenreader in read-only cases. Maybe that's something that's part of the research on read-only that's coming up. When using voice over, a read-only checkbox is announced like any of the other non-disabled checkboxes, so how would a user know that they cannot change the selection? I would think this would probably be a bigger discussion involving all of our team and some accessibility folks, so I'm not going to let it block my approval right now. Just wondered if you had any knowledge I don't!
I reviewed too early before the PR was ready.
32a1113
to
c2cac21
Compare
Good call-out. VoiceOver reads it the same way that you had heard, for React Spectrum's version that uses |
f1def57
to
67057d1
Compare
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 think this is looking good. The read-only behavior works as you described, VoiceOver is announcing the read-only checkboxes in a way that is distinct from other editable checkboxes, and field group no longer has those commas! Just a few things from me!
- love all of the new tests you added
- thanks for going so deep into the
aria-labelled
/aria-readonly
/aria-disabled
attributes. I might ping you for resources so I can keep those straight and know when to use them.
@@ -62,13 +62,19 @@ export const Template = ({ | |||
type="checkbox" | |||
class="${rootClass}-input" | |||
aria-labelledby=${ifDefined(ariaLabelledby)} | |||
aria-disabled=${ifDefined(isReadOnly ? "true" : undefined)} |
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 can look it up on MDN, but I wonder why aria-disabled
adds the "dimmed" part of the screen reader announcement, as opposed to just saying something like "read-only." 🤔
e.preventDefault(); | ||
e.target.checked = !e.target.checked; | ||
} | ||
if (isDisabled || isReadOnly) return; |
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.
Would we ever get to this "or" portion of the code, the || isReadOnly
?
The code would run through the first if(isReadOnly)
, and if it's also disabled, it'll return anyways, but I guess my question is do we need the "or read only" in this if(isDisabled || isReadOnly)
block. Could it run through both if blocks, if a read-only checkbox isn't disabled? Should the return just go in the if(isReadOnly)
block?
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, since readonly is not disabled. This is as intended. If readonly, it keeps checked from changing on click. Then it returns if it's disabled or readonly, and only runs updateArgs to changed the isChecked control value for checkboxes that aren't disabled or readonly.
67057d1
to
7d0aa56
Compare
372e49f
to
a255a12
Compare
@jawinn Just need you to talk a look at the Chromatic changes here. Once those are good to go, we can merge! |
This removes some unnecessary read-only styles. Read-only just needs to override disabled styles; otherwise it uses default styles (for both default and emphasized). Also adjusts template to include aria-disabled when in the read-only state, so screen readers such as VoiceOver do not announce the input as normal. Note that aria-readonly is not used as it is not announced property and MDN states that it is "not relevant" for input with type checkbox.
The previous display of the read-only state, without checkboxes and displaying commas did not match up with any guidelines. This update is to make the display of read-only match with what is implemented in React Spectrum. It also includes aria-labeledby in the template so the group is announced by screen readers.
a255a12
to
dedd54c
Compare
Description
As noted in CSS-833, the CSS, SWC, and RSP implementations of read-only checkboxes/checkbox groups, and the docs surrounding them, conflicted with each other. After discussing with the design team, it was decided that the first step would be for CSS to bring our visual styles in line with React's implementation.
Field group:
aria-labeledby
connected to the group label, so this is announced as a group by the screen reader.Checkbox:
disabled
attribute removed when read-only. Read-only still needs to be focusable / in the tab order.aria-disabled="true"
when read-only, so screen readers do not announce as a normal interactive checkbox. For VoiceOver, this will add "dimmed" now and won't announce the shortcut to check or uncheck. Note that I've not usedaria-readonly
like as seen in React Spectrum as it is not announced by the screen reader (any differently than a normal checkbox) and MDN states that it is "not relevant" for input with type checkbox.This also updates all of the docs surrounding these things and adds a new storybook Docs example for Checkbox. The field group usage notes have been cleaned up as well.
CSS-1004
How and where has this been tested?
Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.
Validation steps
Regression testing
Expected changes:
Validate:
Screenshots
Before:
![Screenshot 2024-10-25 at 4 24 36 PM](https://private-user-images.githubusercontent.com/965114/380317121-5a8347cf-1c77-4655-af24-3e4d686eb040.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5MTg1NjQsIm5iZiI6MTczOTkxODI2NCwicGF0aCI6Ii85NjUxMTQvMzgwMzE3MTIxLTVhODM0N2NmLTFjNzctNDY1NS1hZjI0LTNlNGQ2ODZlYjA0MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxOFQyMjM3NDRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03NGM2NDM3ODk1MmRkMTkxNTdiYjhkY2Y2YjQwMmYyMDE3OTE4NTZjNzA4NWQ3OTMzZGQ5ZDNlMGRlZTIxM2I0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.O0MNxth97XIPaAlhkHj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