Repository navigation
[popover][menu][tooltip][preview card] Don't start a viewport transition when the trigger remounts while closed - #5887
Merged
michaldudak merged 1 commit intoOct 6, 2026
Conversation
…ion when the trigger remounts while closed usePopupViewport tracks the previous trigger with usePreviousValue(open ? activeTrigger : null). Once the popup closes, the tracked value stays null and the previous value keeps pointing at the old trigger element. When the trigger remounts while the popup is closed but kept mounted, the new element differs from that stale previous trigger, so the viewport captured the old content and rendered a [data-previous] container. Only handle trigger changes while the popup is open.
commit: |
Bundle size
PerformanceTotal duration: 432.58 ms +26.92 ms(+6.6%) | Renders: 76 (+0) | Paint: 784.71 ms +42.32 ms(+5.7%)
14 tests within noise — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
michaldudak
marked this pull request as ready for review
October 5, 2026 13:41
michaldudak
requested review from
atomiks,
colmtuite,
flaviendelangle and
jjenzz
as code owners
October 5, 2026 13:41
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a popup with a
Viewportis closed but still mounted (for example viaeventDetails.preventUnmountOnClose()), remounting its trigger starts a morph transition: the viewport renders a[data-previous]container with the old content, as if the user had switched triggers.usePopupViewporttracks the previous trigger withusePreviousValue(open ? activeTrigger : null). After the popup closes, the tracked value staysnull, so the "previous" value keeps pointing at the last open trigger. A remounted trigger is a new element, which differs from that stale value, so the trigger-change effect fires.The fix only handles trigger changes while the popup is open. Opening from a closed state is unaffected: the previous value is
nullat that point, so no morph runs.The hook is shared by
Popover,Menu,TooltipandPreviewCardviewports.Why the existing test didn't catch it
PopoverViewport.test.tsxalready has "does not restart a transition when the active trigger remounts while closed and retained", but its only assertion was that the viewport exists. It now also checks that the popup is closed, that the viewport isn't transitioning, and that there's no[data-previous]container.Validation
*Viewportsuites pass in jsdom and Chromium. ESLint and Prettier pass.Found during an audit of the test suite for tests that can't fail.