Make option and optgroup actually disabled inside disabled select#12205
Make option and optgroup actually disabled inside disabled select#12205josepharhar wants to merge 4 commits intowhatwg:mainfrom
Conversation
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
|
Lgtm |
annevk
left a comment
There was a problem hiding this comment.
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. |
|
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? |
|
I think list boxes are about as old as the |
|
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? |
|
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.) |
|
We resolved on this here, which I think matches Anne's last comment: w3c/csswg-drafts#13383 (comment) |
|
Ok, I replaced the UA stylesheet changes with a change to "actually disabled" which should make option:disabled match inside a disabled select and should otherwise not change how the option's disabled state is used in other algorithms. |
|
The tests checkbox is checked but it links to a chrome cl and it's abandoned? Also need to update the top of the PR description for the committ message to be right. |
| @@ -79217,7 +79217,9 @@ contradict people? | |||
|
|
|||
| <li>an <code>optgroup</code> element that has a <code data-x="attr-optgroup-disabled">disabled</code> attribute</li> | |||
There was a problem hiding this comment.
Should we fix this at the same time?
| <li>an <code>optgroup</code> element that has a <code data-x="attr-optgroup-disabled">disabled</code> attribute</li> | ||
| <li>an <code>optgroup</code> element that has a <code | ||
| data-x="attr-optgroup-disabled">disabled</code> attribute or whose nearest <span>ancestor</span> | ||
| <code>select</code> element is <span data-x="concept-fe-disabled">disabled</span></li> |
There was a problem hiding this comment.
Do we need the same definition for ancestor select that we have for option? We probably want to exclude the same set of intermediate elements, no?
This PR makes option:disabled and optgroup:disabled match when either are inside disabled select elements, without changing the behavior of other algorithms like the selectedness setting algorithm when options are inside disabled selects.
(See WHATWG Working Mode: Changes for more details.)
/semantics-other.html ( diff )