Skip to content
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(foundation): remove readonly from radio button #6438

Merged
merged 25 commits into from
Mar 10, 2023

Conversation

yinonov
Copy link
Contributor

@yinonov yinonov commented Oct 9, 2022

readonly attribute on a radio button violates a WCAG rule. see #6437

there's no evidence readonly should be applied on a radio button. it does on radio group however

as a matter of fact, native radio ignores readonly on interaction

Screen.Recording.2022-10-09.at.9.22.14.mov

readonly on radio button violates a WCAG rule. see microsoft#6437

there's no evidence readonly applies on radio button. it does on radio group however

- [aria-readonly associated roles on MDN](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-readonly#associated_roles) doesn’t list radio
- https://stackoverflow.com/questions/1953017/why-cant-radio-buttons-be-readonly
- https://www.w3schools.com/jsref/dom_obj_radio.asp
@yinonov yinonov requested a review from janechu as a code owner October 9, 2022 06:33
@yinonov
Copy link
Contributor Author

yinonov commented Oct 9, 2022

closes #6437

Copy link
Contributor

@nicholasrice nicholasrice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together! I think there is still a little more that needs to be done here. Previously, the radio itself would prevent changing its checked value when readonly. That behavior essentially needs to be moved instead of removed; the checkbox radio shouldn't get checked when that radiogroup is readonly.

@yinonov
Copy link
Contributor Author

yinonov commented Oct 10, 2022

the checkbox shouldn't get checked when that radiogroup is readonly.

you mean radio shouldn't get checked?

@nicholasrice
Copy link
Contributor

the checkbox shouldn't get checked when that radiogroup is readonly.

you mean radio shouldn't get checked?

Yes, sorry - radio

@yinonov
Copy link
Contributor Author

yinonov commented Oct 11, 2022

I ran the site locally on this branch and it seems to already be covered.

correct me if I'm missing anything here @nicholasrice but this is the expected behavior when radio group is set to readonly correct? preventing any change to radio-buttons on user interaction

Screen.Recording.2022-10-11.at.10.17.53.mov

@nicholasrice
Copy link
Contributor

I ran the site locally on this branch and it seems to already be covered.

correct me if I'm missing anything here @nicholasrice but this is the expected behavior when radio group is set to readonly correct? preventing any change to radio-buttons on user interaction

Screen.Recording.2022-10-11.at.10.17.53.mov

Odd, yes that is my expectation. When I set readonly in storybook on your branch it didn't function correctly, but I'll look again; maybe I messed something up.

@nicholasrice
Copy link
Contributor

I just tried again - setting the readonly attribute on the radiogroup custom element does not prevent the user from changing radio checked values in fast-foundation's storybook app. Try to repro there.

@yinonov
Copy link
Contributor Author

yinonov commented Oct 11, 2022

I just tried again - setting the readonly attribute on the radiogroup custom element does not prevent the user from changing radio checked values in fast-foundation's storybook app. Try to repro there.

you're right. now covered click, keypress and arrow navigation and tabbing into group.

took the liberty to refactor a const to class getter as it repeated in more than 2 places.

https://github.com/yinonov/fast/blob/11ee0292de3667eeadb164ac3a3210694716301c/packages/web-components/fast-foundation/src/radio/radio.ts#L56-L60

Copy link
Contributor

@nicholasrice nicholasrice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with one suggestion. Thanks for making this update!

@yinonov
Copy link
Contributor Author

yinonov commented Oct 16, 2022

Can this be merged?

Copy link
Contributor

@EisenbergEffect EisenbergEffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we removed the tests for the radio itself...do we have an equivalent test for the group?

@yinonov
Copy link
Contributor Author

yinonov commented Oct 25, 2022

Since we removed the tests for the radio itself...do we have an equivalent test for the group?

radio-group had already featured its own readonly member.

anything you think should be added considering this change?

@EisenbergEffect
Copy link
Contributor

Since we removed the tests for the radio itself...do we have an equivalent test for the group?

radio-group had already featured its own readonly member.

anything you think should be added considering this change?

Do we have a test or some other way to ensure that when setting the group to readonly that the individual radios will be readonly? Does the platform handle that for us?

@yinonov
Copy link
Contributor Author

yinonov commented Oct 26, 2022

Since we removed the tests for the radio itself...do we have an equivalent test for the group?

radio-group had already featured its own readonly member.
anything you think should be added considering this change?

Do we have a test or some other way to ensure that when setting the group to readonly that the individual radios will be readonly? Does the platform handle that for us?

How about testing if setting checked property to true on radio actually functions (when radio-group is set to readonly).
Thing is, it's not hardened in the current implementation. setting a readonly radio-group AND radio can be bypassed programmatically.

I guess this should be hardened? in the scope of this PR?

Screen.Recording.2022-10-26.at.22.03.25.mov

@chrisdholt
Copy link
Member

@yinonov @olaf-k Given the refactor for "disabled" behavior in PR, etc and the new tests added, I'd like to rebase this and test once those changes are in and follow-up on the tests/behavior at that point. I think the changes made in #6601 will lend themself more towards ensuring that radios are treated as "readonly" from an interactive standpoint. My only other thought there is ensuring that they're communicated in the a11y tree as readonly...but that we can validate at the same time. Thoughts?

@chrisdholt
Copy link
Member

@yinonov - with the radio/radio group refactor in to solve the state issue it looks like we have some conflicts here. I'd love to get this in. Do we want to resolve conflicts on this branch or just kick off a new one to remove readonly? Happy to move it through quickly regardless of the approach :)

@yinonov
Copy link
Contributor Author

yinonov commented Feb 19, 2023

@yinonov - with the radio/radio group refactor in to solve the state issue it looks like we have some conflicts here. I'd love to get this in. Do we want to resolve conflicts on this branch or just kick off a new one to remove readonly? Happy to move it through quickly regardless of the approach :)

no sweat, resolved the conflicts

@yinonov
Copy link
Contributor Author

yinonov commented Feb 22, 2023

Can this be merged?

@chrisdholt
Copy link
Member

Can this be merged?

It looks like there are some build failures directly related to the PR. Once we get a passing build I'll pull this down, validate the behavior and merge. Thanks!

image

@yinonov
Copy link
Contributor Author

yinonov commented Mar 7, 2023

soz. build works now (locally)

image

@chrisdholt
Copy link
Member

@yinonov looks like there are still a couple failures - I created a PR against your branch to address these (or you can run prettier and yarn locally to address). yinonov#1

Once this is in/updated I'd like to get this in!

@yinonov
Copy link
Contributor Author

yinonov commented Mar 10, 2023

Thanks @chrisdholt. Merged

@chrisdholt chrisdholt merged commit dcf64d0 into microsoft:master Mar 10, 2023
@yinonov yinonov deleted the patch-5 branch March 11, 2023 10:09
janechu pushed a commit that referenced this pull request Jun 10, 2024
* fix(foundation): remove readonly from radio button

readonly on radio button violates a WCAG rule. see #6437

there's no evidence readonly applies on radio button. it does on radio group however

- [aria-readonly associated roles on MDN](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-readonly#associated_roles) doesn’t list radio
- https://stackoverflow.com/questions/1953017/why-cant-radio-buttons-be-readonly
- https://www.w3schools.com/jsref/dom_obj_radio.asp

* remove any evidence of readonly from class

* completely remove any readonly

* Change files

* group slotted radio readonly handling

* docs update

* Update change/@microsoft-fast-foundation-b9885563-e3e8-4c85-a55d-bac04c627fec.json

Co-authored-by: Nicholas Rice <[email protected]>

* Update change/@microsoft-fast-foundation-b9885563-e3e8-4c85-a55d-bac04c627fec.json

Co-authored-by: Nicholas Rice <[email protected]>

* prevent check of radio buttons

* Update packages/web-components/fast-foundation/src/radio/radio.ts

Co-authored-by: Nicholas Rice <[email protected]>

* revert

* remove unused

* FASTRadioGroup to be used as type only

* fixup prettier and API report

---------

Co-authored-by: Nicholas Rice <[email protected]>
Co-authored-by: Rob Eisenberg <[email protected]>
Co-authored-by: Chris Holt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants