Animating Popover API entry and exit without JavaScript delays
A popover can animate in correctly after showPopover() but vanish instantly when closed, because the browser removes it from rendering before the exit transition finishes. The fix is to handle the transition in CSS rather than with JavaScript flags, styling the closed state on the base selector and the visible state on :popover-open. Adding @starting-style gives a predictable first frame when the popover appears. Including display and overlay with allow-discrete in the transition list keeps the element rendered and in the top layer long enough for the exit animation to be seen. JavaScript is limited to checking :popover-open before calling showPopover() or hidePopover(); the pattern does not provide full modal behavior or focus management.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in