Skip to content

Remove readonly attribute from checkboxes, switches, and radios #1413

@devongovett

Description

@devongovett

🐛 Bug Report

It turns out that the <input readonly> attribute only applies to text inputs, not checkboxes and radios according to the HTML spec. See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly.

🤔 Expected Behavior

We should not have the readonly attribute returned by useToggle and useRadio because it is invalid on these elements.

💁 Possible Solution

Instead of readonly, we should use aria-readonly which is allowed on checkbox, switch, and radio roles. Apparently it has inconsistent AT support though, but probably better than nothing. See w3c/aria#1309 (comment). cc. @jnurthen

🧢 Your Company/Team

RSP

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions