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?] Nested machines immediate issue #195

Closed
kybarg opened this issue Feb 24, 2021 · 1 comment · Fixed by #231
Closed

[bug?] Nested machines immediate issue #195

kybarg opened this issue Feb 24, 2021 · 1 comment · Fixed by #231
Labels

Comments

@kybarg
Copy link
Contributor

kybarg commented Feb 24, 2021

When using invoke to run nested machines current doenst't represent deepest child

Here is example
https://codesandbox.io/s/react-robot-bug-example-re781

robot/machine.js

Lines 174 to 181 in 31d8125

let service = {
send(event) {
this.machine = send(this, event);
// TODO detect change
this.onChange(this);
}
};

this quick fix helped, but this looks wrong😁

let service = {
  send(event) {
    this.machine = send(this, event);

    // TODO detect change
-    this.onChange(this);
+    this.onChange(this.child || this)
  }
};
@kybarg kybarg changed the title Nested machines immediate issue [bug?] Nested machines immediate issue Feb 24, 2021
@matthewp matthewp transferred this issue from matthewp/robot-hooks Feb 2, 2023
@afn
Copy link

afn commented Sep 18, 2023

This appears to remain an issue in the latest version (0.4.0).

matthewp added a commit that referenced this issue Dec 27, 2024
This makes it so that we always use the deepest nested service as the `current`.

This is not a breaking change as this is current expected behavior. We were passing `service.child` to be the new current, but not accounting for the possibility of deeply nested machines.

Fixes #195
@matthewp matthewp added the react label Dec 27, 2024
matthewp added a commit that referenced this issue Dec 27, 2024
* Set deepest nested service to current

This makes it so that we always use the deepest nested service as the `current`.

This is not a breaking change as this is current expected behavior. We were passing `service.child` to be the new current, but not accounting for the possibility of deeply nested machines.

Fixes #195

* Add changeset

* update test expectations

* Update packages/robot-hooks/test/test.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants