Skip to content

Conversation

@josepharhar
Copy link
Contributor

@josepharhar josepharhar commented Jul 16, 2025

This PR allows select elements with the multiple attribute to be rendered as a drop-down box when the author explicitly sets the size attribute to 1.

The related issue should be resolved by requiring that mobile browsers and desktop browsers both follow these rules in order to improve cross-platform compatibility.

Fixes #8189

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


/form-elements.html ( diff )
/rendering.html ( diff )

This PR allows select elements with the multiple attribute to be
rendered as a drop-down box when the author explicitly sets the size
attribute to 1.

The related issue should be resolved by requiring that mobile browsers
and desktop browsers both follow these rules in order to improve
cross-platform compatibility.

Fixes whatwg#8189
@josepharhar
Copy link
Contributor Author

This PR implements the plan I wrote in this issue: #8189

The UseCounter data I've collected so far looks OK, but this change might not end up being web compatible. Before I try shipping this and finding out, I'd like feedback on this from Apple and Mozilla.

@mtrootyy
Copy link

The following changes are also required:

4.10.7 The select element
If a select element has a required attribute specified, does not have a multiple attribute specified, and has a display size of 1; and if the value of the first option element in the select element's list of options (if any) is the empty string, and that option element's parent node is the select element (and not an optgroup element), then that option is the select element's placeholder label option.

If a select element has a required attribute specified, and has a display size of 1; and if the value of the first option element in the select element's list of options (if any) is the empty string, and that option element's parent node is the select element (and not an optgroup element), then that option is the select element's placeholder label option.

Aria in HTML(https://w3c.github.io/html-aria/)
select (with NO multiple attribute and NO size attribute having value greater than 1)

select (with NO size attribute having value greater than 1)

select (with a multiple attribute or a size attribute having value greater than 1)

select (with a size attribute having value greater than 1)

@josepharhar josepharhar changed the title Change definition of list box and drop-down box rendering Change definition of select element list box and drop-down box rendering Jul 23, 2025
josepharhar added a commit to josepharhar/html-aria that referenced this pull request Jul 23, 2025
In this HTML PR I am planning on changing the definition of how combobox
vs listbox rendering is done with size and multiple attributes:
whatwg/html#11460

This PR defers to the HTML definition of display size which defines
combobox vs listbox rendering based on multiple and size attributes.
@josepharhar
Copy link
Contributor Author

Thanks @mtrootyy, I updated that section and opened an aria PR: w3c/html-aria#555

@annevk annevk added the topic: select The <select> element label Sep 15, 2025
@foolip
Copy link
Member

foolip commented Sep 16, 2025

@zcorpan do you want to review as well? It touches some things you've worked on I think.

@zcorpan
Copy link
Member

zcorpan commented Sep 17, 2025

Looks good.

I think some things can be tested, e.g. with reftest you can check that <select multiple> is the same as <select multiple size=4>, and that <select multiple size=1 style="field-sizing: content"><option>foo</select> != <select multiple size=4 style="field-sizing: content"><option>foo</select>

@josepharhar
Copy link
Contributor Author

Looks good.

I think some things can be tested, e.g. with reftest you can check that <select multiple> is the same as <select multiple size=4>, and that <select multiple size=1 style="field-sizing: content"><option>foo</select> != <select multiple size=4 style="field-sizing: content"><option>foo</select>

Thanks! I am adding a WPT that does this.

@annevk
Copy link
Member

annevk commented Sep 25, 2025

This PR allows select elements with the multiple attribute to be rendered as a drop-down box when the author explicitly sets the size attribute to 1.

What should happen on platforms that don't have this capability?

@josepharhar
Copy link
Contributor Author

This PR allows select elements with the multiple attribute to be rendered as a drop-down box when the author explicitly sets the size attribute to 1.

What should happen on platforms that don't have this capability?

In chromium, I am implementing this as a popover inside the shadowroot of the select element for desktop platforms. We have also been using a web-based popup document for the single-select picker on windows and linux for as long as I know. By implementing it this way, platform capability doesn't matter, and we could switch it to a native platform implementation later if we want to, as we did for single-select on MacOS.

If we have to carve out an exception in the spec while we wait for MacOS to implement this picker in order to get this PR merged, then we could change it to say that <select multiple size=1> may be either list box or drop down depending on the UA, unlike the other modes that are more well defined.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 30, 2025
It was pointed out that we could write interoperable WPTs for the native
appearance this way:
whatwg/html#11460 (comment)

Bug: 439964654
Change-Id: Iaba3a475cf6f5414619ef7e081e1f257a41a6f01
aarongable pushed a commit to chromium/chromium that referenced this pull request Oct 1, 2025
It was pointed out that we could write interoperable WPTs for the native
appearance this way:
whatwg/html#11460 (comment)

Bug: 439964654
Change-Id: Iaba3a475cf6f5414619ef7e081e1f257a41a6f01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6967020
Reviewed-by: Dominic Farolino <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1523858}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 1, 2025
It was pointed out that we could write interoperable WPTs for the native
appearance this way:
whatwg/html#11460 (comment)

Bug: 439964654
Change-Id: Iaba3a475cf6f5414619ef7e081e1f257a41a6f01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6967020
Reviewed-by: Dominic Farolino <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1523858}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 1, 2025
It was pointed out that we could write interoperable WPTs for the native
appearance this way:
whatwg/html#11460 (comment)

Bug: 439964654
Change-Id: Iaba3a475cf6f5414619ef7e081e1f257a41a6f01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6967020
Reviewed-by: Dominic Farolino <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1523858}
lando-prod-mozilla bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Oct 14, 2025
…a=testonly

Automatic update from web-platform-tests
Add WPTs for SelectMobileDesktopParity

It was pointed out that we could write interoperable WPTs for the native
appearance this way:
whatwg/html#11460 (comment)

Bug: 439964654
Change-Id: Iaba3a475cf6f5414619ef7e081e1f257a41a6f01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6967020
Reviewed-by: Dominic Farolino <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1523858}

--

wpt-commits: 47cbbd49085203c27392abcea9560b372593dd6e
wpt-pr: 55167
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 16, 2025
…a=testonly

Automatic update from web-platform-tests
Add WPTs for SelectMobileDesktopParity

It was pointed out that we could write interoperable WPTs for the native
appearance this way:
whatwg/html#11460 (comment)

Bug: 439964654
Change-Id: Iaba3a475cf6f5414619ef7e081e1f257a41a6f01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6967020
Reviewed-by: Dominic Farolino <domchromium.org>
Commit-Queue: Joey Arhar <jarharchromium.org>
Cr-Commit-Position: refs/heads/main{#1523858}

--

wpt-commits: 47cbbd49085203c27392abcea9560b372593dd6e
wpt-pr: 55167

UltraBlame original commit: 7602c064ac7e95276637e9ac040d27597b59f75d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 16, 2025
…a=testonly

Automatic update from web-platform-tests
Add WPTs for SelectMobileDesktopParity

It was pointed out that we could write interoperable WPTs for the native
appearance this way:
whatwg/html#11460 (comment)

Bug: 439964654
Change-Id: Iaba3a475cf6f5414619ef7e081e1f257a41a6f01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6967020
Reviewed-by: Dominic Farolino <domchromium.org>
Commit-Queue: Joey Arhar <jarharchromium.org>
Cr-Commit-Position: refs/heads/main{#1523858}

--

wpt-commits: 47cbbd49085203c27392abcea9560b372593dd6e
wpt-pr: 55167

UltraBlame original commit: 7602c064ac7e95276637e9ac040d27597b59f75d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 16, 2025
…a=testonly

Automatic update from web-platform-tests
Add WPTs for SelectMobileDesktopParity

It was pointed out that we could write interoperable WPTs for the native
appearance this way:
whatwg/html#11460 (comment)

Bug: 439964654
Change-Id: Iaba3a475cf6f5414619ef7e081e1f257a41a6f01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6967020
Reviewed-by: Dominic Farolino <domchromium.org>
Commit-Queue: Joey Arhar <jarharchromium.org>
Cr-Commit-Position: refs/heads/main{#1523858}

--

wpt-commits: 47cbbd49085203c27392abcea9560b372593dd6e
wpt-pr: 55167

UltraBlame original commit: 7602c064ac7e95276637e9ac040d27597b59f75d
mertcanaltin pushed a commit to mertcanaltin/wpt that referenced this pull request Oct 26, 2025
It was pointed out that we could write interoperable WPTs for the native
appearance this way:
whatwg/html#11460 (comment)

Bug: 439964654
Change-Id: Iaba3a475cf6f5414619ef7e081e1f257a41a6f01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6967020
Reviewed-by: Dominic Farolino <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1523858}
@josepharhar
Copy link
Contributor Author

@annevk if I changed the definition of <select multiple size=1> to be either listbox or dropdown box depending on the platform, would that be sufficient?

@josepharhar
Copy link
Contributor Author

I pushed a commit to make <select multiple size=1> either a listbox or a dropdown box depending on platform support. How does it look?

@josepharhar
Copy link
Contributor Author

I could also rewrite it as an algorithm and/or add a table which shows select with different attributes and what their display type becomes

box</span>.</p>
box</span> if its <span data-x="concept-select-size">display size</span> is greater than 1. If the
<code>select</code> element has a display size of 1, then it may render as a <span>drop-down
box</span> if the platform supports it, otherwise as a <span>list box</span>.</p>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
box</span> if the platform supports it, otherwise as a <span>list box</span>.</p>
box</span> if the platform supports it; otherwise as a <span>list box</span>.</p>

Copy link
Member

Choose a reason for hiding this comment

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

I think this is also dropping some nuance. Shouldn't we prefix all the "box" types with "multi-select"? Because a platform might well support a drop-down box, but the question is really if it supports a multi-select drop-down box.

than 1, is <span>expected</span> to render as a single-select <span>list box</span>.</p>
attribute is absent, is <span>expected</span> to render as a <span>drop-down box</span> if its
<span data-x="concept-select-size">display size</span> is 1, or as a <span>list box</span> if its
<span data-x="concept-select-size">display size</span> is greater than 1.</p>
Copy link
Member

Choose a reason for hiding this comment

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

Similarly here I think dropping "single-select" is a mistake.

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

Labels

topic: select The <select> element

Development

Successfully merging this pull request may close these issues.

Rendering <select> as a listbox is a one-line widget that opens a popup on iOS and Android

5 participants