Repository navigation
[collapsible] Finish closing when the render function removes the panel - #5890
Merged
michaldudak merged 1 commit intoOct 6, 2026
Merged
michaldudak merged 1 commit into
michaldudak merged 1 commit into
Conversation
If Collapsible.Panel's render function drops the element as soon as the panel closes, the ending-phase effect found no panel and returned without unmounting, so the transition never completed and the trigger kept data-ending-style. With no element left to animate, finish the close immediately.
commit: |
Bundle size
PerformanceTotal duration: 513.78 ms -12.56 ms(-2.4%) | Renders: 76 (+0) | Paint: 921.20 ms -33.49 ms(-3.5%)
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:46
michaldudak
requested review from
atomiks,
colmtuite,
flaviendelangle and
jjenzz
as code owners
October 5, 2026 13:46
This was referenced Oct 5, 2026
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.
If
Collapsible.Panel'srenderfunction returnsnullonce the panel closes, the close never finishes. The trigger keepsdata-ending-styleindefinitely, andmountedstaystrue.The ending-phase effect in
useCollapsiblePanelwaits for the panel's close animations and then unmounts. WhenpanelRef.currentisnullit returned early, so nothing ever calledsetMounted(false). With no element left to animate, it now finishes the close right away.The guard sits in the ending-phase effect, not the earlier layout effect. A panel that is absent right after close but mounts again during the ending phase still animates out normally, as covered by "unmounts a panel that mounts after the close has already entered the ending phase".
Accordion uses the same hook, so its panels get the same fix.
Why the existing test didn't catch it
"supports removing the rendered panel as it closes" only asserted things that hold by construction (
aria-expanded, the content being gone,onOpenChange(false)). In practice it only guarded against a crash on the null panel ref. It now also asserts that the trigger has nodata-ending-styleafter closing, and is renamed to "finishes closing when the render function removes the panel element".Validation
Found during an audit of the test suite for tests that can't fail.