-
Notifications
You must be signed in to change notification settings - Fork 664
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
[selectors-4] Introduce :popover-open
pseudo class
#8637
Comments
One thing I suggested in the OpenUI discussion is that |
This also seems like a reasonable suggestion. @jh3y do you know of any popover use cases that would be harmed by not having access to a |
Generally up until now you'd likely do something like |
That distinction seems pretty reasonable to me, yeah. |
@dbaron @tabatkins should I think I'm leaning towards So if an element type can open/close, then it uses |
My understanding was that The only issue I see is "Does |
Could all elements that are in the top-layer have a |
That's what it was at one point last year. There was a But, I think it was removed for naming reasons. |
So we might consider I'm in favor of a) adding |
See [1] for more context, but there are cases where `:open` is ambiguous for popovers. If multiple elements support `:open/:closed`, and [popover] can be applied to any of them, there are situations where an element is both open and closed. For example, `<details popover>` can be closed as a details element and open as a popover, which makes it match both `:open` and `:closed`. It seems that really `:open` and `:closed` should match *elements* that can open and close, and not things that can be made to open or close via an attribute or other mechanism such as JS. This CL adds `:popover` which only applies to popovers in the open state, but it does not yet remove `:open` and `:closed` support for popovers. However, it does convert all of the popover WPTs to use `:popover` instead of either `:open` or `:closed`. [1] w3c/csswg-drafts#8637 Bug: 1307772 Change-Id: I8d840512166ccdb5d5c8abbb7192bbce7177ee88
I still find Sometimes I wonder if the appropriate pseudo is one we discussed before with |
I think the problem is that, due to the issues we've discussed above, it needs to be specific to the API. So it should have "popover" in the name. And akin to |
This is currently under discussion here: w3c/csswg-drafts#8637
See [1] for more context, but there are cases where `:open` is ambiguous for popovers. If multiple elements support `:open/:closed`, and [popover] can be applied to any of them, there are situations where an element is both open and closed. For example, `<details popover>` can be closed as a details element and open as a popover, which makes it match both `:open` and `:closed`. It seems that really `:open` and `:closed` should match *elements* that can open and close, and not things that can be made to open or close via an attribute or other mechanism such as JS. This CL adds `:popover` which only applies to popovers in the open state, but it does not yet remove `:open` and `:closed` support for popovers. However, it does convert all of the popover WPTs to use `:popover` instead of either `:open` or `:closed`. [1] w3c/csswg-drafts#8637 Bug: 1307772 Change-Id: I8d840512166ccdb5d5c8abbb7192bbce7177ee88
See [1] for more context, but there are cases where `:open` is ambiguous for popovers. If multiple elements support `:open/:closed`, and [popover] can be applied to any of them, there are situations where an element is both open and closed. For example, `<details popover>` can be closed as a details element and open as a popover, which makes it match both `:open` and `:closed`. It seems that really `:open` and `:closed` should match *elements* that can open and close, and not things that can be made to open or close via an attribute or other mechanism such as JS. This CL adds `:popover` which only applies to popovers in the open state, but it does not yet remove `:open` and `:closed` support for popovers. However, it does convert all of the popover WPTs to use `:popover` instead of either `:open` or `:closed`. [1] w3c/csswg-drafts#8637 Bug: 1307772 Change-Id: I8d840512166ccdb5d5c8abbb7192bbce7177ee88
I'm not convinced with the parallel with Although given the alternatives would be:
|
That's a good point. |
The CSS Working Group just discussed
The full IRC log of that discussion<TabAtkins> chrishtr: we previous resolved to add :open/:closed to apply when popover is opened or closed.<TabAtkins> chrishtr: <details> has an open/closed concept independent of in the top layer, but it can also be a popover. <TabAtkins> chrishtr: So we need two axises.. <TabAtkins> chrishtr: Proposal is we scope :open/:closed to an element's own notion of being open or closed. New pseudo :popover that's whether it's in the top layer or not. <lea> q+ <TabAtkins> plinss: Nit: whether it's "popped over", not necessarily "in the top layer" <TabAtkins> chrishtr: agreed <TabAtkins> lea: What does the popover pseudo match, exactly? <TabAtkins> ???: matches popovers in the open state <TabAtkins> lea: So what would :popover:closed ever match? <Rossen_> ack lea <TabAtkins> chrishtr: A closed <details> element that's popover <TabAtkins> dbaron: Idea is that it matches popovers who are currently "popover open" <TabAtkins> dbaron: Open and close are reserved for elements that have their own state. <fantasai> :pop-open / :pop-closed ? <Rossen_> ack dbaron <TabAtkins> lea: I think open/closed is fine, but :popover sounds like it matches any popover element, aka with a popover attribute regardless of whether it's popping or not <lea> q+ <TabAtkins> Rossen_: So :popover-open sounds like a refinement? <TabAtkins> chrishtr: Yes, I think :popover-open is descriptive, a little longer but useful <Rossen_> ack lea <TabAtkins> lea: I think we had some issues about defining top layer with CSS, want to make sure this doesn't become an obstacle for that <TabAtkins> plinss: Yes, this just reflects the popover state, not what layer it's in. <flackr> +1 <chrishtr> +1 <TabAtkins> Rossen_: Seeing +1s in the chat. Can we reoslve to add, with the changed name :popover-open? <TabAtkins> plinss: Slight hesitancy due to name getting kinda long. <TabAtkins> plinss: Maybe worth bikeshedding the whole feature name? "popover" is a little weird. <dbaron> popover is a weird name because calling it popup turned out to not be web-compatible <TabAtkins> fantasai: Suggest :pop-open <TabAtkins> dbaron: [reads comment from irc] <TabAtkins> Rossen_: So :popover-open is proposed resolution <TabAtkins> RESOLVED: Add :popover-open pseudoclass, undefined popoverness from :open |
Given verbosity was mentioned in the meeting, another possibility is |
To repeat something I mentioned during the meeting, I think |
A slight correction to what I said in the telecon: we ended up with the name popover after a series of two renaming issues (following the earlier change from element to attribute), but it was the first of them ( |
See [1] for more context, but there are cases where `:open` is ambiguous for popovers. If multiple elements support `:open/:closed`, and [popover] can be applied to any of them, there are situations where an element is both open and closed. For example, `<details popover>` can be closed as a details element and open as a popover, which makes it match both `:open` and `:closed`. It seems that really `:open` and `:closed` should match *elements* that can open and close, and not things that can be made to open or close via an attribute or other mechanism such as JS. This CL adds `:popover` which only applies to popovers in the open state, but it does not yet remove `:open` and `:closed` support for popovers. However, it does convert all of the popover WPTs to use `:popover` instead of either `:open` or `:closed`. [1] w3c/csswg-drafts#8637 Bug: 1307772 Change-Id: I8d840512166ccdb5d5c8abbb7192bbce7177ee88
See [1]/[2] for more context, but there are cases where `:open` is ambiguous for popovers. If multiple elements support `:open/:closed`, and [popover] can be applied to any of them, there are situations where an element is both open and closed. For example, `<details popover>` can be closed as a details element and open as a popover, which makes it match both `:open` and `:closed`. It seems that really `:open` and `:closed` should match *elements* that can open and close, and not things that can be made to open or close via an attribute or other mechanism such as JS. This CL adds `:popover-open` which only applies to popovers in the open state, and it removes `:open` and `:closed` support for popovers. It also converts all of the popover WPTs to use `:popover-open` instead of either `:open` or `:closed`. [1] w3c/csswg-drafts#8637 [2] whatwg/html#9077 Bug: 1307772 Change-Id: I8d840512166ccdb5d5c8abbb7192bbce7177ee88
See [1]/[2] for more context, but there are cases where `:open` is ambiguous for popovers. If multiple elements support `:open/:closed`, and [popover] can be applied to any of them, there are situations where an element is both open and closed. For example, `<details popover>` can be closed as a details element and open as a popover, which makes it match both `:open` and `:closed`. It seems that really `:open` and `:closed` should match *elements* that can open and close, and not things that can be made to open or close via an attribute or other mechanism such as JS. This CL adds `:popover-open` which only applies to popovers in the open state, and it removes `:open` and `:closed` support for popovers. It also converts all of the popover WPTs to use `:popover-open` instead of either `:open` or `:closed`. [1] w3c/csswg-drafts#8637 [2] whatwg/html#9077 Bug: 1307772 Fixed: 1429670 Change-Id: I8d840512166ccdb5d5c8abbb7192bbce7177ee88
See [1]/[2] for more context, but there are cases where `:open` is ambiguous for popovers. If multiple elements support `:open/:closed`, and [popover] can be applied to any of them, there are situations where an element is both open and closed. For example, `<details popover>` can be closed as a details element and open as a popover, which makes it match both `:open` and `:closed`. It seems that really `:open` and `:closed` should match *elements* that can open and close, and not things that can be made to open or close via an attribute or other mechanism such as JS. This CL adds `:popover-open` which only applies to popovers in the open state, and it removes `:open` and `:closed` support for popovers. It also converts all of the popover WPTs to use `:popover-open` instead of either `:open` or `:closed`. [1] w3c/csswg-drafts#8637 [2] whatwg/html#9077 Bug: 1307772 Fixed: 1429670 Change-Id: I8d840512166ccdb5d5c8abbb7192bbce7177ee88 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4373888 Reviewed-by: Joey Arhar <jarhar@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1124869}
See [1]/[2] for more context, but there are cases where `:open` is ambiguous for popovers. If multiple elements support `:open/:closed`, and [popover] can be applied to any of them, there are situations where an element is both open and closed. For example, `<details popover>` can be closed as a details element and open as a popover, which makes it match both `:open` and `:closed`. It seems that really `:open` and `:closed` should match *elements* that can open and close, and not things that can be made to open or close via an attribute or other mechanism such as JS. This CL adds `:popover-open` which only applies to popovers in the open state, and it removes `:open` and `:closed` support for popovers. It also converts all of the popover WPTs to use `:popover-open` instead of either `:open` or `:closed`. [1] w3c/csswg-drafts#8637 [2] whatwg/html#9077 Bug: 1307772 Fixed: 1429670 Change-Id: I8d840512166ccdb5d5c8abbb7192bbce7177ee88 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4373888 Reviewed-by: Joey Arhar <jarhar@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1124869}
As discussed in w3c/csswg-drafts#8637. Tests: web-platform-tests/wpt#39222.
HTML side of this landed: whatwg/html#9077. |
See [1]/[2] for more context, but there are cases where `:open` is ambiguous for popovers. If multiple elements support `:open/:closed`, and [popover] can be applied to any of them, there are situations where an element is both open and closed. For example, `<details popover>` can be closed as a details element and open as a popover, which makes it match both `:open` and `:closed`. It seems that really `:open` and `:closed` should match *elements* that can open and close, and not things that can be made to open or close via an attribute or other mechanism such as JS. This CL adds `:popover-open` which only applies to popovers in the open state, and it removes `:open` and `:closed` support for popovers. It also converts all of the popover WPTs to use `:popover-open` instead of either `:open` or `:closed`. [1] w3c/csswg-drafts#8637 [2] whatwg/html#9077 Bug: 1307772 Fixed: 1429670 Change-Id: I8d840512166ccdb5d5c8abbb7192bbce7177ee88 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4373888 Reviewed-by: Joey Arhar <jarhar@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1124869}
…opovers, a=testonly Automatic update from web-platform-tests Convert `:open` to `:popover-open` for popovers See [1]/[2] for more context, but there are cases where `:open` is ambiguous for popovers. If multiple elements support `:open/:closed`, and [popover] can be applied to any of them, there are situations where an element is both open and closed. For example, `<details popover>` can be closed as a details element and open as a popover, which makes it match both `:open` and `:closed`. It seems that really `:open` and `:closed` should match *elements* that can open and close, and not things that can be made to open or close via an attribute or other mechanism such as JS. This CL adds `:popover-open` which only applies to popovers in the open state, and it removes `:open` and `:closed` support for popovers. It also converts all of the popover WPTs to use `:popover-open` instead of either `:open` or `:closed`. [1] w3c/csswg-drafts#8637 [2] whatwg/html#9077 Bug: 1307772 Fixed: 1429670 Change-Id: I8d840512166ccdb5d5c8abbb7192bbce7177ee88 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4373888 Reviewed-by: Joey Arhar <jarhar@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1124869} -- wpt-commits: e68cb913b7cd3002609729bd2bde85b24ecaff39 wpt-pr: 39222
Hi @mfreed7 I have a working scenario where I need this pseudo class and is also related to your comment about the toggle events not being cancelable when hiding popovers. I created a React component to encapsulate a popover and I need it to be descriptively controlled instead of imperatively. My Popover component receives an <dialog popover="auto" ref={dialogRef}>{children}</dialog> and shows (
I can easily achieve this with const isVisible = getComputedStyle(dialogRef).getPropertyValue('display') === 'block' I see that, as @annevk mentioned, this was already merged to the HTML side, but I can't find if there's been any update on this side |
Right, this is by design, to avoid a slew of footguns. Sounds like you have a way to make your application work, which is good.
You could also use the
It's landed in browsers, so I'm not sure why testing environments wouldn't have it.
Note that this is a bit brittle, since you can set
Right, this is part of the HTML spec, but doesn't appear yet in the selectors spec. @tabatkins @fantasai is it easy (and appropriate) to get |
We recently resolved to add general-purpose
:open
and:closed
pseudo classes, which apply to "things that can open and close". While not defined in CSSWG, the stated intention was to include things like<details>
,<select>
,<dialog>
, and Popover.@jakearchibald recently raised the issue that in some cases, this is ambiguous, because there are multiple "ways" that something can be open or closed, and both might apply at the same time. Take, as an example,
<details popover>
, which can be "open" as a popover, but "closed" as a details, or vice versa. There's no way for these to be disambiguated on the basis of:open
or:closed
alone.It is a bit unclear whether fullscreen elements should be included as "something that can open and close", but it's possible. That allows the possibility of a fullscreen
<details>
element which can be both open and closed. But fullscreen elements have a dedicated pseudo,:fullscreen
, which allows one to disambiguate that state of openness vs. others.It would seem that we need another such pseudo for popovers, because any element can also be a popover, and can therefore run into this dual-states problem. We discussed this in OpenUI, and proposed
:popover
as a pseudo class that applies only to popovers that are open (as a popover). That would allow developers to do:The text was updated successfully, but these errors were encountered: