-
-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Bug report
I've checked documentation and searched for existing issues
I've made sure my project is based on the latest MST version
Fork this code sandbox or another minimal reproduction.
Sandbox link or minimal reproduction code
https://codesandbox.io/s/mobx-state-tree-todolist-forked-kxzoqw
Above you can see my minimal reproduction of graphics editor. We have a BoxStore with an UndoMiddleware("history" property) where we save our graphics elements and Focus store(for UI) where we save array of references to these graphics elements.
Then we do such steps:
Add the new Box to the BoxStore.
Focus Box(add reference to this box into Focus store).
Remove the Box from the BoxStore(at this step, the reference to the Box invalidates).
Undo the previous action(recover the removed Box).
And after last step, not only Box is recovered, but also the reference to this box in the Focus store is recovered too.
From the UndoMiddleware Docs I understand that only changes in targetStore (in out case it is BoxStore) should be tracked. But as I see if the action invokes from the targetStore and this action change the state of secondary store(in our case it is Focus), all the patches (includes the changing of the Focus store) are writing to the UndoMiddleware.
image
Describe the expected behavior
Only patches from targetStore should be written to the UndoMiddleware.
Describe the observed behavior
All the patches are written to the UndoMiddleware.