Fix(collapse): fix race condition when rapidly clicking accordion triggers #41893
+41
−2
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.
Description
Fixes a race condition in the Collapse component that can cause multiple accordion panels to open simultaneously when rapidly clicking different triggers in sequence. Accordion behavior should ensure that opening one panel closes any other open panel within the same parent.
Problem
When rapidly clicking different accordion triggers in sequence, multiple panels can remain open.
Steps to reproduce:
Root causes identified:
SELECTOR_ACTIVES- the selector.collapse.show, .collapse.collapsingis incorrect because.collapse.collapsingnever matches: when.collapsingis added,.collapseis removed (and vice versa). As a result, elements in transition were not reliably detected.activeChildren.length && activeChildren[0]._isTransitioningonly inspected the first active element and did not distinguish between opening vs closing transitions, causing improper blocking logic.During the investigation, I also discovered a test case
should allow accordion to target multiple elements, which verifies that a single trigger can control multiple targets. The same race condition bug affects this scenario as well - when rapidly switching between triggers, all corresponding panels open.Solution
SELECTOR_ACTIVESto.collapse.show, .collapsingto properly match elements during transition._isShowingflag to track the opening animation direction.activeChildrenby shared triggers - elements controlled by the same trigger should not block each other (this enables proper handling of multiple targets per trigger)._isShowingflag across all active elements instead of checking_isTransitioningon the first one only.Type of changes
Checklist
npm run lint)Related issues
Fixes #41883