Repository navigation
[popups] Restore viewport morphing after reopen - #5010
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,182.32 ms 🔺+222.57 ms(+23.2%) | Renders: 50 (+0)
…and 6 more (+1 within noise) — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review (GPT-5.5)Approve ✅ No actionable issues found; the patch resets only the stale trigger guard across closed/unmounted cycles and the regression test reproduces the bug on base. 1. Bugs / Issues (None)Root Cause & Patch AssessmentThe fix targets the stale state directly: Test Coverage AssessmentI verified the added regression test fails on freshly fetched
Performance / Operational Risk
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a kept-mounted popup viewport edge case where morphing snapshots could be skipped after closing and reopening, by ensuring per-open-cycle trigger handling state is reset on close/unmount.
Changes:
- Reset
lastHandledTriggerRefwhenever the popup is closed or becomes unmounted to avoid stale trigger-guard state across open cycles. - Add a browser-only regression test covering close → reopen → trigger switch for a
keepMountedPopover viewport.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/react/src/utils/usePopupViewport.tsx | Clears the “last handled trigger” ref when open is false or the popup is not mounted, restoring morphing behavior after reopen. |
| packages/react/src/popover/viewport/PopoverViewport.test.tsx | Adds a regression test (non-JSDOM) to ensure morphing containers are created after a kept-mounted popup closes and reopens. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
A kept-mounted popup viewport could skip its morphing snapshot after closing, reopening through one trigger, then switching back to the trigger it had handled before close. Reset the handled-trigger guard when the popup is closed so each open cycle can animate trigger switches normally.
Root cause
The last handled trigger was kept in a ref across close/reopen cycles, so a later switch to that same trigger was ignored.
Changes