Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[selectmenu] Add CSS selector to consistently select selectmenu parts #645

Closed
xiaochengh opened this issue Dec 8, 2022 · 7 comments
Closed
Labels
needs edits This is ready for edits to be made select These are issues that relate to the select component stale

Comments

@xiaochengh
Copy link

There's currently no way to select a <selectmenu> part, especially if it's provided externally.

For example, if we want to select the listbox part:

  • selectmenu::part(listbox) only works if we are using the listbox in the UA shadow DOM
  • selectmenu [behavior=listbox] should work for most cases when the listbox is author-provided
  • However, there doesn't seem to be a way if, e.g., the selectmenu is in a shadow DOM, and the listbox is passed through from an outer tree scope in a way similar to [selectmenu] Accept "option" elements through multiple slots #565

While this doesn't seem to be a big issue from the author's perspective (since the author should always know how to select the part they provided), it blocks the browser from adding a proper UA style sheet to position the listbox (as in this Chromium patch).

Should we introduce new CSS pseudo element selectors that can select the parts, regardless of where they are (whether in UA shadow DOM or not)? For example, selectmenu::behavior(listbox).

This may be of interest for developers as well.

aarongable pushed a commit to chromium/chromium that referenced this issue Dec 9, 2022
This patch removes all the proprietary positioning code for selectmenu
listbox popover, and replaces it with a UA style sheet. This also
makes anchor positioning a dependency for selectmenu.

There's a caveat that we don't have a way in UA style sheet to ensure
selecting an externally provided listbox [1]. This patch works around
it with `selectmenu [behavior=listbox]` and also leaves a TODO.

[1] openui/open-ui#645

Bug: 1197720
Change-Id: I6308089e4be858432969b87eabd27b9e0ea6c435
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4082046
Commit-Queue: Xiaocheng Hu <[email protected]>
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Reviewed-by: Mason Freed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1081249}
@mfreed7 mfreed7 added the select These are issues that relate to the select component label Jan 17, 2023
@gregwhitworth
Copy link
Member

This is a great question and one I'll add to the agenda to discuss this week. I do agree that if this blocks the potential for a default UA stylesheet then we need a solution.

@gregwhitworth gregwhitworth added the agenda+ Use this label if you'd like the topic to be added to the meeting agenda label Jan 23, 2023
@xiaochengh
Copy link
Author

Maybe it will also be useful for library authors, when they want to build a component based on a selectmenu and want to set a base style to it?

@css-meeting-bot
Copy link

The Open UI Community Group just discussed [selectmenu] Add CSS selector to consistently select selectmenu parts.

The full IRC log of that discussion <gregwhitworth> Topic: [selectmenu] Add CSS selector to consistently select selectmenu parts
<gregwhitworth> github: https://github.com//issues/645
<hdv> xiaocheng: the issue is, we don't have a way to consistently select parts of the selectmenu, regardless of where it actually is
<hdv> xiaocheng: the part:: selector exists but that doesn't work for all cases
<hdv> xiaocheng: the more complicated case is if the selectmenu is part of a bigger component and the listbox is slotted in from an outer tree scope, we don't have a way to select it
<masonf> q?
<masonf> q+
<hdv> xiaocheng: so I am proposing we introduce a new selector that selects in all cases. This should be very useful for UA stylesheets, and also for library authors
<gregwhitworth> ack masonf
<hdv> [ technical issue ]
<masonf> I'm text only now.
<masonf> No, Joey and Xiaocheng can speak for me.
<masonf> 1-
<masonf> FYI, I've tried two different browsers, Chrome and Safari.
<masonf> This is clearly a Jitsi bug though - my audio got through to Joey with no issues.
<gregwhitworth> https://meet.google.com/bhk-agxm-qgq
<gregwhitworth>
<hdv> masonf: clarifying question: is the proposal 'make it so no matter if the listbox in lightdom, shadow dom, slotted element, the ::part selector would still work' ?
<hdv> xiaocheng: yes
<gregwhitworth> q+
<hdv> masonf: that makes sense, that makes it easy from a developer's point of view too, it's the same CSS however you do it
<hdv> gregwhitworth: web compat question: 'behavior' is interesting… but this is still a part… should we maybe see if we can expand part and make it so that it behaves as what you're looking for?
<hdv> masonf: the difference is that… as the part pseudo selector works now, it won't work if the part comes from the light DOM
<hdv> xiaocheng: yes and I think there's no way it can work, as it is defined as something in the Shadow DOM
<hdv> gregwhitworth: ok … I am supportive of that pseudo selector… I can foresee there are naming resolution, because 'behavior' is quite specific… could be a light DOM specific selector for instance
<hdv> gregwhitworth: I can foresee CSSWG may have a request like that
<hdv> gregwhitworth: do you want to put forward a proposed resolution?
<hdv> xiaocheng: should I propose a name too? how about selectmenupart?
<hdv> gregwhitworth: I doubt that will fly
<hdv> masonf: I like behavior
<gregwhitworth> Proposed Resolution: We recommend to add a new CSS pseudo selector of ::behavior which will allow selection within a shadow or light DOM
<masonf> +1
<gregwhitworth> Resolved: We recommend to add a new CSS pseudo selector of ::behavior which will allow selection within a shadow or light DOM

@gregwhitworth gregwhitworth added needs edits This is ready for edits to be made and removed agenda+ Use this label if you'd like the topic to be added to the meeting agenda labels Feb 15, 2023
@josepharhar
Copy link
Collaborator

css-meeting-bot didn't pull the important part out of the details:

Resolved: We recommend to add a new CSS pseudo selector of ::behavior which will allow selection within a shadow or light DOM

@josepharhar
Copy link
Collaborator

@github-actions
Copy link

There hasn't been any discussion on this issue for a while, so we're marking it as stale. If you choose to kick off the discussion again, we'll remove the 'stale' label.

@github-actions github-actions bot added the stale label Sep 21, 2023
@lukewarlow
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs edits This is ready for edits to be made select These are issues that relate to the select component stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants