Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: #4866

Closed
acrobid opened this issue Apr 24, 2024 · 3 comments
Closed

Bug: #4866

acrobid opened this issue Apr 24, 2024 · 3 comments

Comments

@acrobid
Copy link

acrobid commented Apr 24, 2024

XState version

XState version 5

Description

In a parallel parent state, if a child state sends an event to a sibling, the behavior in the visual editor does not match the behavior of the actual machine.

Child A is "On" and child "B" is "Off", and event turns event "B" "On", and then an after event turns "A" "Off".

(Also, is there a better way for a single event to affect 2 parallel states.

Expected result

In the editor, the final state is:

A: Off
B: On

Actual result

In Stackblitz:

A: Off
B: Off

Reproduction

https://stately.ai/registry/editor/aaf32c01-ba6d-4ef2-8b99-2c41e835826f?machineId=d06b5a5d-6597-4154-8d6c-e3cd6198bef0&mode=Simulate

Additional context

XState 5
Stackblitz:
https://stackblitz.com/edit/w2u9xw?file=machine.ts

@acrobid acrobid added the bug label Apr 24, 2024
@davidkpiano
Copy link
Member

Better workaround: it's preferable to raise events instead:

after: {
  '500': {
    actions: raise({ type: 'Disconnect' }),
  },
},

https://stackblitz.com/edit/w2u9xw-yuhzvv?file=machine.ts

@acrobid
Copy link
Author

acrobid commented Apr 24, 2024

Thank you! That solves it.

Should I close the issue? Is the disconnect between the editor and actual behavior simply due to me using it improperly?

@davidkpiano
Copy link
Member

Thank you! That solves it.

Should I close the issue? Is the disconnect between the editor and actual behavior simply due to me using it improperly?

Not your fault; the editor may be slightly misleading regarding this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants