Repository navigation
Description
What is the issue with the HTML Standard?
https://random-stuff.jakearchibald.com/popover-hint/
Videos below have audio.
Weirdness 1 - does showing a hint popover hide unrelated auto popovers?
nested-hint.mp4
Unnested, opening an auto popover then a hint popover shows both. Nested, opening an auto popover then a hint popover hides the auto popover.
The nested behaviour seems wrong, but here's where it happens in the spec. And here's a test.
Proposal: Opening a hint popover should never directly cause auto popovers to hide.
Weirdness 2 - does showing a hint popover hide unrelated hint popovers?
av1.mp4
Opening a nested hint popover then an unnested hint popover shows both hints. Opening an unnested hint popover then a nested hint popover hides the first.
The nested popover=hint ends up in the "auto" stackToAppendTo, which seems really weird, but may be the source of the weirdness.
Proposal: Opening a hint should close other hints, except those that are 'parent' to it.
Weirdness 3 - does clicking outside an auto popover stack hide it?
av1.mp4
Opening an unnested auto popover and an unnested hint popover, then clicking within the hint popover, leaves both popovers visible, even though the auto popover is unrelated to the hint. Clicking outside an auto or hint popover should close it.
Proposal: Clicking outside of auto and hint popovers should consistently close them, except popovers that are 'parent' to a clicked popover.
Weirdness 4 - does hiding an auto popover hide unrelated hint popovers?
av1.mp4
When an auto popover hides, it also hides all hint popovers.
This seems bad in cases where auto popovers may hide without user interaction, such as a timeout, or as part of DOM element removal (virtual lists).
Proposal: Hiding an auto popover should only hide 'child' auto/hint popovers, and should not impact unrelated popovers.
Weirdness 5 - is showing an auto popover within an hint popover allowed?
This is now being discussed in #12346
auto-inside-hint.mp4
Opening an auto popover within a hint popover leaves things in a broken state.
Apparently you "can't" do this, but the only web-standard source of that rule is the name of this test.
Proposal: If this shouldn't be allowed, we should prevent it happening (throwing/logging an error), or find some non-broken way for it to happen (treat the auto popover as a hint).
Activity
mfreed7 commentedon Mar 24, 2026
See my comment here #12305 (comment) which I think applies to this issue also.
jakearchibald commentedon Mar 24, 2026
So, the answer to "does opening a hint close a sibling auto popover?" is 'sometimes', and that's fully intentional? I cannot think of a case where this behaviour is beneficial, yet it's a gotcha in simple multi-level menus.
I don't think this is a documentation issue. I think the requirements got confused along the way, or the requirements were incorrectly spec'd.
Are you around for this week's WHATNOT meeting?
jakearchibald commentedon Mar 24, 2026
I can't find any discussion around making the behaviour I documented in this issue intentional, or why it would be desirable. I did find #9776 (comment):
…Which smells like a lot of changes didn't receive proper review.
jakearchibald commentedon Mar 24, 2026
bramus commentedon Mar 24, 2026
I looked at all the videos and to me the current behavior looks inconsistently weird indeed.
This seems like a reasonable model that I could wrap my head around.
One question though: when you say “close all [X] popovers except those that are ancestors” you mean that the popovers themselves are nested? Knowing that popovers can live anywhere in the DOM, the “nested” ones could just be sibling elements. Therefore it might be better to base yourself on the triggering element that shows the nested popover. As in: Close all [X] popovers except for the popover that contains the triggering source element that shows the new popover. The wording here might need some tweaking to more clearly convey the message and to play nice with multiple levels of popovers.
jakearchibald commentedon Mar 24, 2026
Yeah, you're right. I don't have the opener logic in there. I deleted my shitty spec. Here's a less shitty one…
jakearchibald commentedon Mar 24, 2026
Assuming that hint popovers are intended for hover tooltip style things, here's a set of behaviours that I think make sense:
autopopover within ahintpopover is weird. We should either prevent this from happening, or treat thatautopopover as ahintpopover for the rest of this ruleset.auto+hintstack.autopopover will close otherautopopovers, except its ancestor popovers.autopopover will close allhintpopovers (unless it's nested in ahintpopover, in which case it's a failure or we treat it as ahintpopover)hintpopover will close otherhintpopovers, except its ancestor popovers.hintpopover will not closeautopopovers.hintpopover will also close 'child'hintpopovers.autopopover will also close 'child'hint&autopopovers. It will not close other popovers (includinghint). This allows anautopopover to be closed on a timeout without impacting tooltiphintpopovers.auto&hintpopovers, except any popover that contains the clicked item, and its parent popovers.manualpopovers continue to operate independently. Closing/opening one does not impactauto/hintpopovers.Here's a pseudo-spec proposal:
Infra
autoRootedPopoverStackis a stack of open popovers in theautostate.hintRootedPopoverStackis a stack of open popovers in thehintorautostate.These stacks can be 'getters' the operate on the top-layer.
hintStackParentis an open popover in theautostate, or null. Initially null.Some diagrams of potential states:
When a
popoverToOpen(HTMLElement) is to be opened viasource(HTMLElement or null):popoverToOpenis in themanualstate, then just open it and return.popoverToOpenParentbe the topmost popover ancestor ofpopoverToOpenandsource(algorithm below).hintRootedPopoverStackis not empty:popoverbe the last item inhintRootedPopoverStack.popoverToOpenParentispopover, then:popoverToOpenis in theautostate, then throw an error indicating that anautopopover cannot be opened inside ahintpopover. Option B: Otherwise, we continue, andpopoverToOpenis effectively shown as ahintpopover.popoverToOpenontohintRootedPopoverStack.popoverToOpenand return.popover.hintRootedPopoverStack.hintStackParentto null.popoverToOpenis in theautostate, then:autoRootedPopoverStackis not empty:popoverbe the last item inautoRootedPopoverStack.popoverToOpenParentispopover, then break.popover.autoRootedPopoverStack.popoverToOpenontoautoRootedPopoverStack.popoverToOpenand return.popoverToOpenis in thehintstate):hintRootedPopoverStackis empty.popoverToOpenontohintRootedPopoverStack.popoverToOpenParentis not null, then:popoverToOpenParentis in theautostate.hintStackParenttopopoverToOpenParent.popoverToOpenand return.To get the topmost popover ancestor of
popover(HTMLElement) and source (HTMLElement or null):allPopoversbe a list that's a concatenation ofautoRootedPopoverStackandhintRootedPopoverStack.popoverAncestorIndexbe the index of the last item inallPopoverswhose flattened tree containspopover, otherwise infinity.sourceAncestorIndexbe infinity.sourceis not null, then setsourceAncestorIndexto the index of the last item inallPopoverswhose flattened tree containssource, otherwise infinity.ancestorIndexbe the minimum ofpopoverAncestorIndexandsourceAncestorIndex.ancestorIndexis infinity, then return null, otherwise returnallPopovers[ancestorIndex].To hide
popoverToHide(HTMLElement):popoverToHideis in themanualstate, then just hide it and return.hintRootedPopoverStackcontainspopoverToHide, then:popoverbe the last item inhintRootedPopoverStack.popover.hintRootedPopoverStack.popoverispopoverToHide, then return.autoStackIndexbe the index ofpopoverToHideinautoRootedPopoverStack, otherwise -1.autoStackIndexis not -1.autoPopoversToHidebe the slice ofautoRootedPopoverStackfromautoStackIndexto the end.autoPopoversToHidecontainshintStackParent, then:hintRootedPopoverStackis not empty:popoverbe the last item inhintRootedPopoverStack.popover.hintRootedPopoverStack.hintStackParentto null.popoverbe the last item inautoRootedPopoverStack.popover.autoRootedPopoverStack.popoverispopoverToHide, then return.On click
parentPopoverOrNullbe the closesthintorautopopover to the clicked element, otherwise null.hintRootedPopoverStackis not empty:popoverbe the last item inhintRootedPopoverStack.parentPopoverOrNullispopover, then break.popover.hintRootedPopoverStack.hintRootedPopoverStackis empty, then sethintStackParentto null.autoRootedPopoverStackis not empty:popoverbe the last item inautoRootedPopoverStack.parentPopoverOrNullispopoverorparentPopoverOrNullishintStackParent, then return.popover.autoRootedPopoverStack.If we went with this model:
Weirdness 1 - solved. Opening the
hintpopover would not close the siblingautopopover, as closing items in theautostack is something onlyautopopovers can do (step 4). This makes it consistent with the non-nested popover behaviour.Weirdness 2 - solved. Because the nested
hintpopover is in thehintstack (unlike the current spec that puts it in theautostack), then only onehintpopover would be shown at a time, as the other(s) are hidden as part of step 3. The only case where multiple hint popovers can be shown is when they're nested (step 3.ii).Weirdness 3 - solved. On click, if a
hintpopover is cleared, unrelatedautopopovers are also closed.Weirdness 4 - solved. When a popover hides, it only hides its 'children' popovers, not all popovers.
Weirdness 5 - two options. Opening the
autopopover inside thehintpopover would not hide thehintpopover, as it's an ancestor (step 3.ii). As per step 3.ii.a, it would either throw at this point (since you can't putautopopovers inhintpopovers), or it allows it by treating it as ahintpopover, and putting it in thehintstack.All of these feel way more intuitive than what currently happens, but I assume this model breaks some other use-cases? What are they?
jakearchibald commentedon Mar 26, 2026
[-]popover=hint inconsistent behavior nested vs unnested[/-][+]popover=hint has multiple weird and inconsistent behaviours[/+]lukewarlow commentedon Mar 26, 2026
Without having read the full comments here, here's my thoughts.
TLDR I agree each of those cases feels unintuative to authors.
Weirdness 1 :
That’s definitely not desirable imo, the whole point of hint is that it should not close auto popovers, the fact they’re nested inside of an auto popover should not change that.
Weirdness 2:
That also feels very strange, like you say a world in which nested hints don’t close root ones, could make sense but in that case opening the root one shouldn’t close the nested ones. I think I would prefer if a hint just always closes non-ancestor hints. But the current behaviour is wrong imo.
Weirdness 3:
I wonder what the spec reason for that is? I could be persuaded that maybe this is desirable behaviour to able to copy text out of a tooltip or something, but it doesn’t immediately feel like it should be the behaviour based on my understanding of the spec.
Weirdness 4:
I get that showing an auto does close hints but I don’t know that closing an auto should have any impact on hints (other than descendants).
Weirdness 5
We should probably just make showPopover/togglePopover throw when the source is inside a hint popover. (Likewise popovertarget/commandfor would just do nothing). I agree this isn’t something that feels useful but it also shouldn’t be broken like this.
mfreed7 commentedon Mar 26, 2026
So generally I think I need more time to work through all of the weirdness examples here. However, it feels like at least a few of them, and perhaps all of them (?) are due to how
display:noneworks, and really nothing to do with popover logic. I mentioned a bit of that in this comment: #12305 (comment). It would be super helpful to disambiguate that from any other issues. I.e. I believe in the OP here you're using the word "close" to mean two different things, in different cases. In one case, you mean the "hide popover algorithm" is run on a popover, and in others, you mean that a parent element in the layout tree hasdisplay:noneand therefore the popover element is not rendered. I'm not sure we can/should try to solve the second issue, since it's a lot bigger than just popovers, as shown in the comment I just linked above.The answer to this should be "never". Hints are subordinate to autos, so opening a hint shouldn't close an auto. The "hide all popovers until" algorithm should encode this behavior. Step 8 should keep a
hintpopover from closing anyautopopovers.I'm still paging back in all of these discussions from 2-3 years ago, but this paragraph of the explainer attempts to capture the logic of the existing stack: Popover Stacks.
jakearchibald commentedon Mar 26, 2026
I don't think any of them are related to this. "Weirdness 5" has some side-effect because of
display:none, but https://random-stuff.jakearchibald.com/popover-hint-flat/ here are the same demos but without nesting the popover elements themselves, and the behaviour is still weird/broken.19 remaining items
jakearchibald commentedon Apr 2, 2026
oh wow, oops. Edited.
jakearchibald commentedon Apr 2, 2026
TODO for me: Spin out a new issue for weirdness 5.
mfreed7 commentedon Apr 3, 2026
So I implemented all of your proposals in Chromium, and played around with it a bit. The new behavior indeed feels a lot better. (It hasn't landed yet, but hopefully I can get that done in the next few days.) I added a test case for each of the "weirdnesses". Along the way, just a few (three to be exact) other WPTs needed to change slightly. I'm also encouraged by that lack of general fallout in the WPTs.
So I guess check off "adding WPTs" from the to-do list. If you're up for writing the spec PR, then I think we're close here, modulo weirdness 5. (For that, I implemented the throwing behavior, at least for now.)
jakearchibald commentedon Apr 3, 2026
Oh wow! Ok, I'll try to get the spec PR up next week (today and Monday are holidays in the UK)
jakearchibald commentedon Apr 8, 2026
I've split out weirdness 5 to #12346
Implement new/revised popover=hint behavior
Implement new/revised popover=hint behavior
Implement new/revised popover=hint behavior
Implement new/revised popover=hint behavior
Bug 2039528 [wpt PR 59237] - Implement new/revised popover=hint behav…
Note inconsistent `popover=hint` behaviors in implementations (#29676)
Bug 2039528 [wpt PR 59237] - Implement new/revised popover=hint behav…
fix(popover): auto/hint hierarchy (auto inside a hint, nested hints o…