Bug report
Version info:
mobx 5.9.0
mobx-state-tree 3.10.2
mst-middlewares 3.10.2
When using the UndoManager middleware's withoutUndo method, in an action which causes multiple patches, if any one of the patch-creating changes is made within a withoutUndo call, all of the patches from that action are excluded from the undo history.
Sandbox link or minimal reproduction code
https://codesandbox.io/s/7mxk54x7nx?fontsize=14
const { types } = require(`mobx-state-tree`);
const { UndoManager } = require(`mst-middlewares`);
let undoManager = {};
const setUndoManager = targetStore => {
undoManager = UndoManager.create({}, { targetStore });
};
const store = types
.model(`Person`, {
name: types.string,
age: types.number
})
.actions(self => {
setUndoManager(self);
return {
setName(name) {
undoManager.withoutUndo(() => {
self.name = name;
});
},
setAge(age) {
self.age = age;
},
setInfo({ name, age }) {
self.setName(name);
self.setAge(age);
}
};
});
const person = store.create({ name: `Jon`, age: 20 });
person.setInfo({ name: `Bob`, age: 50 });
console.log(undoManager.history.length); // 0
Describe the expected behavior
I would expect this to generate 2 patches, 1 for each property changed. I would expect the patch to the name property not to be recorded in the undo history and the patch for the age property to be added to the undo history.
Describe the observed behavior
No patches are added to the undo history at all. If you remove the withoutUndo, 2 patches are created in the history.
Bug report
Version info:
mobx 5.9.0
mobx-state-tree 3.10.2
mst-middlewares 3.10.2
When using the UndoManager middleware's
withoutUndomethod, in an action which causes multiple patches, if any one of the patch-creating changes is made within awithoutUndocall, all of the patches from that action are excluded from the undo history.Sandbox link or minimal reproduction code
https://codesandbox.io/s/7mxk54x7nx?fontsize=14
Describe the expected behavior
I would expect this to generate 2 patches, 1 for each property changed. I would expect the patch to the
nameproperty not to be recorded in the undo history and the patch for theageproperty to be added to the undo history.Describe the observed behavior
No patches are added to the undo history at all. If you remove the
withoutUndo, 2 patches are created in the history.