Open Bug 2038043 Opened 1 day ago Updated 1 day ago

Add support for readonly in formset

Categories

(Firefox :: General, enhancement)

enhancement

Tracking

()

UNCONFIRMED

People

(Reporter: teo.eterovic, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36

Steps to reproduce:

I've opened a draft PR for: https://github.com/whatwg/html/issues/10293 (see last comment for details) and PR: https://github.com/whatwg/html/pull/12424

The approach mirrors disabled: a readonly attribute on <fieldset> propagates read-only state to descendant <input> (in states where readonly is meaningful), <textarea>, and form-associated custom elements.

Controls like checkbox, radio, button, and <select> are unaffected. Anything inside the first <legend> child is excluded.

A formReadonlyCallback is introduced on form-associated custom elements parallel to formDisabledCallback.

This would create behavior consistent with the disabled attribute, but the real benefit would be to use it for web components that have form association implemented to be handled through a form manager - for example dynamic forms / form builder.

OS: Unspecified → All
Hardware: Unspecified → All

Spec issue: https://github.com/whatwg/html/issues/10293

Spec PR: https://github.com/whatwg/html/pull/12424

WPT tests (tentative): https://github.com/web-platform-tests/wpt/pull/59741

Summary

Add a readonly content attribute to <fieldset> that propagates a
read-only state to descendant form controls that support being readonly,
mirroring the existing disabled attribute on <fieldset>.

Behavior

  • The attribute is reflected as HTMLFieldSetElement.readOnly
  • Affected descendants:
    • <input> in states that support readonly (text, search, url, tel,
      email, password, date, month, week, time, datetime-local, number)
    • <textarea>
    • Form-associated custom elements, via a new formReadonlyCallback
  • Unaffected: checkbox, radio, file, button/submit/reset/image,
    range, color, hidden, <button>, <select>
  • Descendants of the first <legend> element child are exempt
    (matching the disabled exemption)
  • Nested fieldsets propagate; the legend exemption applies per fieldset
    and does not extend to legends of nested fieldsets

Why

Authors today have to manually toggle readonly on every form control
inside a section. <fieldset disabled> already provides bulk disabling;
read-only state — which is semantically distinct (values still submit,
focus and selection still work) — has no equivalent.
This is also very useful for web components - Form-Associated Components attachInternals

Tests

WPT tests are landed as .tentative at
html/semantics/forms/the-fieldset-element/readonly-*.tentative.html.
They will turn green once this is implemented.

Asking for

Implementer signal on the WHATWG PR checklist — please leave a comment
on https://github.com/whatwg/html/pull/12424 indicating
interest (or concerns), and link this bug.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, but is not confident enough to move the bug to that component.

Component: Untriaged → General
You need to log in before you can comment on or make changes to this bug.