Skip to content

Fix select option enabled selector#12205

Open
josepharhar wants to merge 1 commit intowhatwg:mainfrom
josepharhar:disabledhover
Open

Fix select option enabled selector#12205
josepharhar wants to merge 1 commit intowhatwg:mainfrom
josepharhar:disabledhover

Conversation

@josepharhar
Copy link
Contributor

@josepharhar josepharhar commented Feb 26, 2026

option elements can match :enabled while inside a disabled select, so the option:enabled selectors also need to include select:enabled. More context here: w3c/csswg-drafts#13383

(See WHATWG Working Mode: Changes for more details.)


/rendering.html ( diff )

option elements can match :enabled while inside a disabled select, so
the option:enabled selectors also need to include select:enabled. More
context here: w3c/csswg-drafts#13383
@lukewarlow
Copy link
Member

Lgtm

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some more blame research is required here. We check disabled state of ancestor optgroup but not select. Why is that? Perhaps an oversight?

@josepharhar
Copy link
Contributor Author

I think some more blame research is required here. We check disabled state of ancestor optgroup but not select. Why is that? Perhaps an oversight?

This was added in chromium and webkit here, which references the spec:

I blamed the spec, and I got to 80aba5d which didn't seem to cite any reasons.

I'll see what tests fail if I make options become disabled when they are in a disabled select, but I anticipate that more changes would be needed to make this work, if we can at all.

@lukewarlow
Copy link
Member

When did listbox get added to the spec? One thought I had was perhaps option doesn't look at select because the assumption was you won't see the picker when select is disabled.

I can't see this being a behaviour people are relying on?

@annevk
Copy link
Member

annevk commented Mar 3, 2026

I think list boxes are about as old as the select element itself. It at least had size and multiple since its introduction to HTML in 3.2. https://www.w3.org/TR/html401/interact/forms.html#disabled suggests that the intent of <select disabled> was that it would disable the subtree. I strongly suspect this is an oversight.

@josepharhar
Copy link
Contributor Author

I took a closer look at implementing behavior where options become disabled inside disabled selects. Consider the following:

<select disabled>
  <option disabled>disabled option</option>
  <optgroup disabled label=optgroup>
    <option>option in disabled optgroup</option>
  </optgroup>
  <option>option in disabled select</option>
</select>

In current behavior, at least in chromium, "option in disabled select" gets selected by default. It could be fairly complicated to preserve this behavior, but we could try. I'd be afraid of breaking sites by changing how this currently works. Does this still seem preferrable to making the change in this PR?

@annevk
Copy link
Member

annevk commented Mar 4, 2026

Thanks for looking into it! My inclination would be to distinguish explicitly disabled and disabled and make the pseudo-class use the latter concept. (There might even be precedent for this.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants