Repository navigation
fix(outliner): a move up or down never carries a block into another page - #13606
yuxi-liu-wired wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| 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 |
There was a problem hiding this comment.
🔴 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
…he fork carries logseq#13607 The cherry-pick of logseq#13607 committed the test file with its conflict markers; this keeps both test sets.
…he fork carries logseq#13607 The cherry-pick of logseq#13607 committed the test file with its conflict markers; this keeps both test sets.
a4bb894 to
922e546
Compare
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.
922e546 to
e3d08c4
Compare
|
Combined with the other PRs that change the same files into #13783. |
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-downindeps/outliner/src/logseq/outliner/core.cljstakes 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-testandfrontend.handler.editor-testpass.