material-web icon indicating copy to clipboard operation
material-web copied to clipboard

Add "readonly" to interactive form controls like checkbox and switch

Open masaoliou opened this issue 2 years ago • 3 comments

I need the property readonly in elements textfield, textarea, switch, and select so I can focus and click on these element and initialize some stuff, even with attribute readonly set. Property disabled isn't for me because it prohibits all interactions on the element.

masaoliou avatar Sep 13 '23 11:09 masaoliou

Can you explain the need for readonly on switch and select? native <input type="checkbox"> and <select> do not offer any readonly functionality for readonly.

Additionally textfield and area should have a readOnly property and readonly attribute on them already

e111077 avatar Sep 17 '23 23:09 e111077

A need for readonly property is pretty well summarized in https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-readonly

In particular:

When you want to indicate that an interactive element works but is not editable Read-only elements are still relevant to the user, so you should not prevent the user from navigating to the element or its focusable descendants or copying the value.

The problem with disabled is that the element is not operable, and keyboard navigation will completely ignore them.

I would add checkbox , radio and slider to the list.

christophe-g avatar Sep 28 '23 06:09 christophe-g

We'll need this as well for things like checkbox list items, where the checkbox itself is not interactive, but just a visual display of state. The list item itself is interactive and changes the readonly checkbox/switch/radio to match its state.

This could be a good community contribution!

asyncliz avatar Sep 28 '23 16:09 asyncliz