-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Labels
issue: bugDescribes why the code or behaviour is wrongDescribes why the code or behaviour is wrong
Description
Description
eventUtils.filter(...) attempts to merge related events into a single change for broadcast purposes, but in doing so it modifies the underlying events which remain in the undo/redo history. Those modified events can become no-op events even if they weren't before, reporting true for isNull(). The next time filtering is performed, these now no-op events are skipped by the merging process and important data is lost, resulting in an incorrect state in the workspace after performing undo + redo + undo.
Reproduction steps
- Open the advanced playground.
- From the Math category, drag a new number value block into a workspace, with the default value "123".
- Click the number to select it, and type "1", "2", "3", producing three block change events with the following data:
- {oldValue: 123, newValue: 1},
- {oldValue: 1, newValue: 12},
- {oldValue: 12, newValue: 123},
- Undo. The filtering and merging process overwrites the newValue of the first event to 123, and then the first event is run backward, using its oldValue 123 to update the field. The events now look like:
- {oldValue: 123, newValue: 123}, (this is now a no-op!)
- {oldValue: 1, newValue: 12},
- {oldValue: 12, newValue: 123},
- Redo. The first block is skipped entirely and the second block is now the basis for merging. It is merged with the third block and its newValue 123 is used to update the field.
- {oldValue: 123, newValue: 123}, (still a no-op, ignored during filtering/merging)
- {oldValue: 1, newValue: 123},
- {oldValue: 12, newValue: 123},
- Undo again. The first event is ignored entirely, so the second event's oldValue 1 is assigned to the field, resulting in an incorrect state for the field. The field did not originally have the value 1.
Metadata
Metadata
Assignees
Labels
issue: bugDescribes why the code or behaviour is wrongDescribes why the code or behaviour is wrong