Skip to content

fix(outliner): a move up or down never carries a block into another page - #13606

Closed
yuxi-liu-wired wants to merge 4 commits into
logseq:masterfrom
yuxi-liu-wired:fix/move-up-down-one-page
Closed

yuxi-liu-wired wants to merge 4 commits into
logseq:masterfrom
yuxi-liu-wired:fix/move-up-down-one-page

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes logseq/db-test#1318.

Give today's journal the blocks a, b, c and yesterday's journal e, f. On the Journals page, Ctrl+click a, then e, and press Alt+Shift+Up: e leaves yesterday's journal and lands in today's, right after a. Clicking e first, then a, moves a into yesterday's journal instead.

move-blocks-up-down in deps/outliner/src/logseq/outliner/core.cljs takes 1 target from 1 end of the selection and moves every selected block there, so a selection over 2 pages carries the blocks of 1 page into the other. For a block at the top of a page the up branch's guard compares the page's :block/page (nil) with the page itself and passes.

A selection whose top-level blocks are on more than 1 page now does not move, up or down. A move up or down never changes a block's page: a second commit (from review) also checks where the move lands, so the first or last block of a nested page does not move into the sibling page before or after it (pages under a namespace parent are siblings, and the up branch took the page before as left-left, the down branch the page after as the parent's right sibling).

New test test-move-blocks-up-down-across-pages: a selection over 2 pages, and the only block of a nested page between 2 sibling pages moved up and down. It fails on master (page 1 holds a, e, b, c after the move; the nested block moves up into the page before) and passes with the change. frontend.modules.outliner.core-test, frontend.worker.undo-redo-test and frontend.handler.editor-test pass.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment on lines +1475 to +1481
pages (set (map #(:db/id (:block/page (d/entity db (:db/id %)))) top-level-blocks))]
(cond
;; a move up or down stays in 1 page: its target comes from 1 end of
;; the selection, so a selection over 2 pages would carry the blocks
;; of 1 page into the other
(> (count pages) 1)
nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Last block escapes its page on move down

When a nested page has a following sibling page, moving its last block down passes pages and enters the sibling page. The down branch uses get-right-sibling of the parent page as its target.

Learn more

Pages can have sibling pages under a parent, as page-with-parent-and-order sets :block/parent and :block/order. When the last block of such a page has no right sibling, the down branch asks for the parent's right sibling and targets that page. The new pages set contains only the selected block's source page; it never compares the destination page. move-block then updates the block and descendants to the target page.

Example: Page A and page B are siblings under a parent page. A contains only block X. Moving X down finds B as A's right sibling and reparents X to B, instead of keeping X on A.

Recommended fix: Check the resolved destination with get-target-block-page before calling move-blocks in both directions, rejecting any destination that differs from the selected ordinary blocks' page. Add a regression test with two sibling namespace pages and a move down from the last block of the first.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 6, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 6, 2026
…he fork carries logseq#13607

The cherry-pick of logseq#13607 committed the test file with its conflict
markers; this keeps both test sets.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 8, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 8, 2026
…he fork carries logseq#13607

The cherry-pick of logseq#13607 committed the test file with its conflict
markers; this keeps both test sets.
@yuxi-liu-wired
yuxi-liu-wired force-pushed the fix/move-up-down-one-page branch from a4bb894 to 922e546 Compare October 11, 2026 06:20
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 11, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
move-blocks-up-down takes 1 target from 1 end of the selection and moves
every selected block there. With blocks of 2 pages selected (Ctrl+click
a on today's journal and e on yesterday's, then Alt+Shift+Up), e landed
in today's journal right after a (db-test logseq#1318).

A selection whose top-level blocks are on more than 1 page now does not
move.
The first or last block of a nested page moved into the page before or
after it: up took the page before as left-left, down took the parent's
right sibling, which for a nested page is the next page. Both branches
now check where the move lands.
The one-page check read a nested page's own :block/page (none), so a
selection of nested pages, or of a nested page and a block beside it,
counted as 2 pages and did not move. A node's page is now its
:block/page or, for a page, its parent.
move-blocks-up-down went over the outliner's 55-line large-vars limit with the one-page check. The page helpers are now move-pages.
@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Combined with the other PRs that change the same files into #13783.

@yuxi-liu-wired
yuxi-liu-wired deleted the fix/move-up-down-one-page branch October 21, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move up on a selection spanning 2 journal pages moves a block into the other page

1 participant