html icon indicating copy to clipboard operation
html copied to clipboard

A (hidden) popover inside a dialog gets detached

Open erikblomqvist-huma opened this issue 2 months ago • 2 comments

Issue

When a popover, that is hidden by default (display: none), lives inside a <dialog> element, gets shown through showPopover(), it's being detached from its anchor.

If the popover is shown by default (display: block) and modal gets moved around, e.g. via transform, it seems to "reattach".

This behavior seem to differ slightly between browser engines. What's consistent is that the target is never correctly attached when hidden by default.

Chromium 142: When popover is shown by default, it attaches correctly at start and when modal is moved, but detaches when showPopover() is triggered through hover

Firefox Nightly 146: When popover is shown by default, the popover is detached by default, reattaches when moving the modal, but detaches when showPopover() is triggered through hover

Safari 26: When popover is shown by default, the popover is centered by default, reattaches when moving the modal, but detaches when showPopover() is triggered through hover

Reproducible demo

https://codepen.io/huma-erik/pen/raxqVBZ

erikblomqvist-huma avatar Nov 03 '25 11:11 erikblomqvist-huma

cc @mfreed7 @josepharhar

annevk avatar Nov 20 '25 12:11 annevk

At least in Chrome, the behavior as of the latest Canary is "correct": you can drag the dialog and the tooltip stays anchored, even with a transformed dialog. In 142 I agree it's "broken". I bisected the change to this:

https://chromium.googlesource.com/chromium/src/+/02c2db183ee66a3f0c61a8a6c2ee48a89d94f98d

Which means the fix you're looking for is already (recently) part of the CSS spec for anchor positioning:

https://github.com/w3c/csswg-drafts/issues/8584

mfreed7 avatar Nov 20 '25 20:11 mfreed7