designsystemet icon indicating copy to clipboard operation
designsystemet copied to clipboard

Select: remove readOnly?

Open eirikbacker opened this issue 5 months ago • 1 comments

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 use Input with value and readonly to display readOnly 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.

eirikbacker avatar Sep 12 '24 08:09 eirikbacker