fix(core): enter parallel default configuration when targeting an unvisited history child#5589
Merged
davidkpiano merged 1 commit intoJul 2, 2026
Conversation
… child Targeting a history state that is a direct child of a parallel state, when the parallel state had not been visited yet and the history state had no default target, resolved to an empty target set and silently dropped the transition. Fall back to the parallel state itself so its initial configuration is entered, matching the compound-state case.
🦋 Changeset detectedLatest commit: 9d60a51 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 |
davidkpiano
approved these changes
Jul 2, 2026
This was referenced Jul 2, 2026
Merged
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.
Targeting a history state that is a direct child of a
parallelstate silently does nothing when that parallel state has not been visited yet and the history state has no defaulttarget. The machine stays in the source state instead of entering the parallel state's initial configuration, and no error is thrown.Cause
In
resolveHistoryDefaultTransition(packages/core/src/stateUtils.ts), a history node with no configuredtargetreturnsparent.initial. For a compound parent that is the single initial child, so entry works. For aparallelparent there is no single initial child, soparent.initialproduces a transition withtarget: []; the empty target set flows through the entry machinery and the transition no-ops. The compound case is already documented and tested ("should execute actions of the initial transition when a history state without a default target is targeted and its parent state was never visited yet"); the parallel case was missed.Fix
When the history node has no default target and its parent is a
parallelstate, return the parallel state itself as the target. The existing entry logic then enters every region at its initial state, which is the parallel state's initial configuration. Compound parents are unchanged.Testing
Added deep and shallow history variants to
packages/core/test/history.test.ts. They fail on the current code (value staysoff) and pass with the fix.pnpm test:corestays green (1746 passed) andpackages/coretypechecks clean. Changeset included.