Closed
Description
What is the issue with the HTML Standard?
The popovertarget
attribute "connects" a button to a popover, in three key ways:
- it creates nested popovers, if the invoking button is inside another popover.
- it modifies the sequential focus navigation order, so that the invoked popover comes "next" in keyboard focus order.
- it sets up
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:
popover.togglePopover({invoker: element});
popover.showPopover({invoker: element});
popover.hidePopover({invoker: element});
Some questions:
- can
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.) - can
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. - are there a11y implications of only creating the ARIA relationships at invocation time? The declarative API can set those up even before the button is clicked.