-
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 an imperative way to set popover invoker relationships #10442
Comments
while exposing an aria-expanded state won't work on just any element unless it has an implicit or explicit ARIA role that allows for that state to be exposed - maybe this is a way to allow those who have been asking to use popover with their custom button elements the ability to identify their invoker, and if 'any element' is allowed, then `div[role=button]' would be too.
depends on exactly what you mean by this. but for instance, if you just have a button in a web page, and an aria-expanded property is only added to it once clicked, then the state change is generally not exposed to screen readers by browsers. from what i remember, there is no signal for the AT to listen for simply by the addition of the expanded property to a button - but rather, only if the expanded property exists and its state changes. again, that's at least what i recall - would have to do some testing to determine if that's changed at all. |
@scottaohara and I just discussed this, and I broadly agree with the points made above. One interesting conclusion:
Perhaps that's as it should be for an imperative API - we can try to fix things up as best as possible, but typically the author will need to make sure they're doing things correctly. E.g. manually setting |
This either needs element to be a HTMLElement (or child of), or some of the spec will need updating as currently popover invoker is an HTMLElement (see https://html.spec.whatwg.org/#popover-invoker) togglePopover isn't quite a simple addition because of the optional force boolean argument. We'd have to either take the compat hit of changing the argument type, or do the slightly unfortunate thing of allowing an argument of type boolean or dict where the dict has invoker and force as optional members. |
Note #9144 (comment) |
Out of curiosity what's the API design looking like specifically for togglePopover given it already has the optional Boolean argument? |
I'm open to whatever makes the most sense. I implemented (in Chrome) the easiest/most compatible thing:
i.e. either the boolean or the options bag (which contains the boolean). |
This includes two related changes: 1. The `showPopover()` and `togglePopover()` methods now include an options bag that allows setting the popover invoker. 2. Popover invokers (declaratively or imperatively set) now create an implicit anchor reference for that popover. This new behavior was resolved in the [WHATWG/CSSWG/OpenUI joint task force meeting on June 26, 2024](whatwg#9144 (comment)). Closes whatwg#10442 Closes whatwg#10675
I put up a spec PR containing the proposal detailed above: #10728 |
This includes two related changes: 1. The `showPopover()` and `togglePopover()` methods now include an options bag that allows setting the popover invoker. 2. Popover invokers (declaratively or imperatively set) now create an implicit anchor reference for that popover. This new behavior was resolved in the [WHATWG/CSSWG/OpenUI joint task force meeting on June 26, 2024](whatwg#9144 (comment)). Closes whatwg#10442 Closes whatwg#10675
What is the issue with the HTML Standard?
The
popovertarget
attribute "connects" a button to a popover, in three key ways:aria-details
andaria-expanded
relationships between the invoker and the popover.It seems like there should be an imperative way to create that relationship. This was agreed in OpenUI in openui/open-ui#1024 (comment), and at the WHATWG/CSSWG/OpenUI task force in #9144 (comment).
This issue proposes a simple addition to the three popover APIs:
Some questions:
element
be any element? Or just buttons? (Feels to me like it should be able to be any element, since the relationships created don't really depend on the button-ness of the invoker.)element
cross a shadow root, in either direction? As long as there's no way to retrieve the invoker element, it seems to be this could be done safely without exposing shadow roots.The text was updated successfully, but these errors were encountered: