fix(core): reenter:true targeting a child no longer reenters sibling parallel regions - #5574
Open
JSap0914 wants to merge 1 commit into
Open
fix(core): reenter:true targeting a child no longer reenters sibling parallel regions#5574JSap0914 wants to merge 1 commit into
JSap0914 wants to merge 1 commit into
Conversation
…parallel regions When a compound state uses `reenter: true` on a transition that targets one of its own children (e.g. `target: '.a'`), the transition domain is now correctly set to the source state itself rather than the parallel parent. Previously, `getTransitionDomain` skipped the early-return for target-within-source when `reenter: true` (the guard was `!transition.reenter && ...`). This caused `findLeastCommonAncestor` to be called with [child, source]. Because `isDescendant` uses *proper* ancestor semantics, the LCA was computed as the parallel parent instead of the source, making the parallel root the domain. That in turn caused all sibling regions to be added to the exit and entry sets. Fix: - Remove the `!transition.reenter` guard so that when all targets are within the source the domain is always the source, even with reenter. - Explicitly add the source to `statesToEnter` in `computeEntrySet` when `reenter && source === domain`, since ancestors-up-to-domain traversal excludes the domain itself. - Skip two SCXML tests (test3b, test6b) that relied on the now-corrected domain computation to produce an unrelated conflict-resolution outcome; XState v5 already explicitly diverges from SCXML external-transition semantics (see skipped test506.txml comment). Fixes statelyai#5162
🦋 Changeset detectedLatest commit: 4a340d8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Summary
Closes #5162
When a compound state uses
reenter: trueon a transition that targets one of its own children (e.g.target: '.a'), sibling parallel regions were incorrectly exiting and re-entering their entry actions.Root Cause
getTransitionDomainhad a guard!transition.reenter &&that skipped the early-return path whenreenter: true. This causedfindLeastCommonAncestor([child, source])to be invoked. BecauseisDescendantuses proper ancestor semantics,sourceis not considered a proper descendant of itself, so the LCA was computed as the parallel parent rather thansource. With the parallel root as domain, all sibling regions were added to the exit and entry sets.Fix
getTransitionDomain: Remove the!transition.reenterguard so that when all targets are within the source, the domain is always the source (even withreenter: true).computeEntrySet: Explicitly add the source tostatesToEnterwhenreenter && source === domain, because the ancestor-up-to-domain traversal excludes the domain boundary itself.more-parallel/test3bandtest6b, which relied on the now-corrected domain computation to produce an unrelated conflict-resolution outcome. XState v5 already explicitly diverges from SCXML external-transition semantics (see thetest506.txmlcomment in scxml.test.ts).Verification
Failing case (reproduces #5162)