Skip to content

Merged events producing no-op event result in incorrect state after repeated undo/redo. #7026

@johnnesky

Description

@johnnesky

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

  1. Open the advanced playground.
  2. From the Math category, drag a new number value block into a workspace, with the default value "123".
  3. 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},
  4. 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},
  5. 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},
  6. 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

No one assigned

    Labels

    issue: bugDescribes why the code or behaviour is wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions