Skip to content

Moving a nested block and the block after its parent can reverse them #1297

Closed

Description

@yuxi-liu-wired

Steps

  1. On a page with blocks a, b (children b1, b2), c, add a child block under a.
  2. Ctrl+click b2, then Ctrl+click c.
  3. Move the selection into a block on another page.
  4. Undo twice, then redo twice.

Expected

The target holds b2, c.

Actual

The target holds c, b2.

Cause

get-top-level-blocks in deps/outliner/src/logseq/outliner/core.cljs decides that the selection is in reverse order by comparing the :block/order values of the first 2 selected blocks, even when they have different parents, where the 2 values are unrelated. consecutive-block? treats b2 (the last child of b) and c as consecutive, so move-blocks skips the page-order sort. In the steps above, b2 has order "b9R" and c has "b9S"; undoing the move gives c the new order "b9Q", so the redo compares "b9R" with "b9Q" and moves c first. A first move reverses the 2 blocks in the same way whenever their order values compare like that.

Found with a property-based test of random outliner operation sequences with undo and redo.

Activity

  1. yuxi-liu-wired commented on Oct 6, 2026

    @yuxi-liu-wired
    Author
  2. yuxi-liu-wired commented on Oct 27, 2026

    @yuxi-liu-wired
    Author

    Fixed by logseq/logseq#13783, which replaces #13605 (closed). When the first two selected blocks have different parents, the selection is now put in page order, so a last child and the block after its parent are no longer reversed on redo. test-move-last-child-and-next-block-keeps-page-order pins it; it fails on master (the target holds 5, 4).

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