Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Bug: onDone appears in state.nextEvents even if compound node is not in final state #403

Open
eponymous301 opened this issue Feb 25, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@eponymous301
Copy link

Description

Given machine in initial state (see image), state.nextEvents includes an entry for the onDone transition. (And transition can be fired by clicking on onDone in the inspector)

Screen Shot 2023-02-25 at 3 02 19 PM

Expected result

  • state.nextEvents == [ "start" ]
  • onDone transition is disabled in inspector

Actual result

  • state.nextEvents == [ "done.state.test.First State", "start" ]
  • onDone transition is enabled in inspector
    • clicking causes "Second State" to become the current state.

Reproduction

https://stately.ai/viz/dafd285c-17f4-429e-b16c-9b58d0e96222

Additional context

Local env is below, but viz URL for "Reproduction" above also shows onDone enabled and clickable (although State.nextEvents is not exposed in UI so I can't verify that it also includes an entry for it)

OS X 10.15.7
node v18.12.1
vue@3.2.47
xstate@4.36.0
@xstate/vue@2.0.0
@xstate/inspect@0.7.1

xstate-viz-app@0.8.5 running locally

@eponymous301 eponymous301 added the bug Something isn't working label Feb 25, 2023
@eponymous301
Copy link
Author

NOTE: using 'Simulate' in Stately Studio at stately.ai/registry/new shows expected behavior (onDone not enabled until "First State" is in final child state "new state 2"

@davidkpiano
Copy link
Member

This is currently expected behavior for .nextEvents, since it is only responsible for showing the events that are part of the active state nodes in the state; not for whether or not an event will cause a transition.

For that, state.can(...) should be used.

But thanks for pointing this out in the XState Viz repo; moving it there.

@davidkpiano davidkpiano transferred this issue from statelyai/xstate Mar 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants