designsystemet
designsystemet copied to clipboard
Select: remove readOnly?
Bringing this up again, native HTML <select>
has no readOnly
state, because you can't interact with it anyway. In HTML, only <input readonly>
is possible if wanting to display some data in a form-field design.
- This is already discussed in https://github.com/digdir/designsystemet/issues/1659, but I would like to point out that creating a "fake" readOnly requires a lot of unnecessary Javascript (which makes it harder to create a solution when we go framework independent).
- The current solution is not accessibility compliant to have the current solution (could work around by adding
aria-disabled
though this is a a bit weird too) - The current solution disables ability to select text, which is expected to be able to do when using
readonly
in other components - I see Aksel has created a fake readOnly, but still thinks this is the wrong solution 😇
- I would suggest that we remove
readOnly
functionality on Select, and rather document that you can useInput
with value and readonly to displayreadOnly
data - We could alternatively automatically render
<Select readOnly>
as a<input readOnly>
under the hood, though this will not be possible for HTML/CSS-only version of the Designsystem.