-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add the :open pseudo-class #10126
Add the :open pseudo-class #10126
Conversation
These pseudo-selectors are defined in CSS here: https://drafts.csswg.org/selectors-4/#open-state
@nt1m maybe you're interested in this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this!
Has it been discussed whether they should match other pickers besides select, like color pickers, date pickers, etc.? Basically all the things that showPicker() triggers. |
That sounds great! I just used it on the elements that the css spec listed, but I don't see any reason why we shouldn't support I think this might get nuanced even more than |
I wonder if we can turn "If no such UI applies to element" into a rendering concept and branch |
As far as I understand the reason showPicker() doesn't return a success boolean was because browsers explicitly didn't want to "leak" the information about whether they show a picker on these elements, I think it was for forwards compatability so they'd be free to add them in future without people relying too much on them existing or not in a given UA. I personally think it would be great if we could apply these to those elements and support the feature detection for showPicker(). |
If it was decided that |
I'd be interested to hear more about this, is there a conversation you can point to? |
Absolutely, so there's an open issue regarding lack of feature detection for showPicker() here and that links to a TAG design review comment here It seems the lack of support detection was the hang up that lead to an unsatisfied resolution in TAG. My earlier remark that "browsers" didn't want to leak might be a mischaracterisation upon further reading. But the sentiment is the same, it was concluded that it was an undesirable compat trade off. |
Thanks! @domenic do you think these issues still apply with this pseudo class? |
It depends exactly how they're defined. Consider a case like Similarly, if we go with the "neither That said, I don't feel that the interop and compat issues with revealing the picker-UI-or-not status of a control are blocking. I think they're reason to be cautious, but if all the implementers in the room are willing to eat those interop and future-compat costs, then from a HTML editor perspective, I have no objection. |
I suppose that essentially argues for making |
Following up on this another place where we'd potentially like to do something that exposes picker UI existence is with invokers. If we were to add showPicker actions to invokers then it would seem logical (though I'm no expert so this might be wrong) that it exposes an aria-expanded state based on the inputs picker state? If aria-expanded should be added it would be unfortunate if we couldn't because of this compat risk (though admittedly it's not currently detectable in code so maybe it's fine?) |
Something I've just thought of. Would it be worth exposing this on datalist elements? They're kind of input pickers but also they're a separate element so idk if input:open matching necessarily makes sense for a datalist? |
I feel like input:open makes more sense than datalist:open since we are planning on doing select:open rather than select::picker(select):open |
WebKit bug at https://bugs.webkit.org/show_bug.cgi?id=280637 |
I think that making :closed match "all elements" makes sense based on domenic's explanation for compat. I added another line for input elements and said that they should always match either open or closed. I also made all select elements match either open or closed regardless of whether they have list-box rendering or not. |
Is one possibility to ship :open and not :closed initially? Making :closed match things that can never be open feels odd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Luke that starting out with just :open
is better, but we should run that by the CSS WG.
Just dropping this as an FYI: |
:closed was resolved to be removed for now, so I'm removing it from this PR: w3c/csswg-drafts#11039 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josepharhar thanks so much, I pushed some nits and this looks good to me now. Can you fill out the PR template?
Isn't that from before the :not() selector though? Either way I think dropping closed for now is better than defining it as :not(:open) in case we want to define it properly in future where it's not equivalent. |
This pseudo-class are defined in CSS here: https://drafts.csswg.org/selectors-4/#open-state
:open matches on details and dialog elements when they are open. :open matches on select and input elements if they are in a state which supports a picker popup and that picker popup is open.
:open
pseudo-class mdn/content#37153(See WHATWG Working Mode: Changes for more details.)
/input.html ( diff )
/semantics-other.html ( diff )