Skip to content

Undo of deleting 2 blocks fails and clears the history when one's node property points at the other #1331

Closed

Description

@yuxi-liu-wired

Steps

  1. On a page, type 2 blocks, "first" and "second" below it.
  2. On "first", add a property of type node (for example "related") and set it to the block "second".
  3. Select both blocks (click "first", Shift+click "second") and press Delete.
  4. Press Ctrl+Z.

Expected

Both blocks are back, and "first" has "related" set to "second".

Actual

Nothing comes back, and the undo history is gone: another Ctrl+Z does nothing, not even undo the property from step 2. The worker logs Nothing found for entity id [:block/uuid <uuid of "second">].

If "second" holds the property pointing at "first" instead, the undo works.

Cause

The undo inverse of a delete (build-inverse-delete-blocks in deps/outliner/src/logseq/outliner/op/construct.cljc) restores each selected block with its own :insert-blocks op, in turn. Each block's payload holds its ref values as [:block/uuid ...] (build-insert-block-payload, sanitize-ref-value), so the op that restores "first" looks up "second" before the next op has inserted it, and throws. The failed history action then clears the history (apply-history-action in src/main/frontend/worker/undo_redo.cljs: a result that is neither applied nor skippable runs clear-history!).

Found by the property test of logseq/logseq#13461 (seed 777) and replayed on upstream master 16c4ed1a0 with 2 sibling blocks: holder above target fails with the error above, the history empty after it; holder below target restores both. The same with the app's worker transaction pipeline registered. A target inside the other selected block's subtree (a child of it) fails the same way. On the branch of logseq/logseq#13466 (undo from DataScript's record on graphs without sync) all 4 cases restore both blocks and the property value.

Activity

  1. tiensonqin commented on Sep 30, 2026

    @tiensonqin
    Contributor

    Fixed by logseq/logseq#13458, which has been merged into master. Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions