Skip to content

Fix placeholder label option to allow wrapper elements - #12893

Open
keithamus wants to merge 1 commit into
whatwg:mainfrom
keithamus:fix-placeholder-label-option-to-allow-wrapper-elements
Open

Fix placeholder label option to allow wrapper elements#12893
keithamus wants to merge 1 commit into
whatwg:mainfrom
keithamus:fix-placeholder-label-option-to-allow-wrapper-elements

Conversation

@keithamus

@keithamus keithamus commented Sep 2, 2026

Copy link
Copy Markdown
Member

This changes the check for an ancestor optgroup instead.

Fixes #12892.

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

This changes the check for an ancestor optgroup instead.

Fixes whatwg#12892.

@annevk annevk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm surprised we don't say anything about the option element being disabled here.

Also, even if we fix this, I wonder if we need another issue to address this for appearance base:

If a select element contains a placeholder label option, the user agent is expected to render that option in a manner that conveys that it is a label, rather than a valid option of the control. This can include preventing the placeholder label option from being explicitly selected by the user. When the placeholder label option's selectedness is true, the control is expected to be displayed in a fashion that indicates that no valid option is currently selected.

@annevk

annevk commented Sep 3, 2026

Copy link
Copy Markdown
Member

Why did you omit the template? It seems like this should come with tests and possibly browser bugs?

@annevk annevk added the do not merge yet Pull request must not be merged per rationale in comment label Sep 3, 2026
@keithamus

Copy link
Copy Markdown
Member Author

Added template back in; @annevk do you have a webkit bug or shall I file one?

@annevk

annevk commented Sep 3, 2026

Copy link
Copy Markdown
Member

I don't. Also, how does this relate to #12855? cc @sb3nder

@sb3nder

sb3nder commented Sep 3, 2026

Copy link
Copy Markdown

This PR resolves one point in #12855 👍.

@sb3nder

sb3nder commented Sep 3, 2026

Copy link
Copy Markdown

I'm surprised we don't say anything about the option element being disabled here.

Currently, it's up to authors how the placeholder option behaves, usually the hidden or disabled attribute is added.


I interpret the rendering paragraph as describing behavior that could be represented by the following example CSS:

If a select element contains a placeholder label option, the user agent is expected to render that option in a manner that conveys that it is a label, rather than a valid option of the control.

select option:placeholder {
  color: color-mix(currentColor 60%, transparent);
}

This can include preventing the placeholder label option from being explicitly selected by the user.

(It's a bit sus to do this by default; I'm not aware of any UAs that do it.)

select option:placeholder {
  display: none;
}

When the placeholder label option's selectedness is true, the control is expected to be displayed in a fashion that indicates that no valid option is currently selected.

select:invalid::field-content,
select:invalid > button:first-child {
  color: color-mix(currentColor 60%, transparent);
}

:user-invalid {
  border-color: red;
}

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

Labels

do not merge yet Pull request must not be merged per rationale in comment

Development

Successfully merging this pull request may close these issues.

Placeholder label option checks if option's parent is a select.

3 participants