Repository navigation
fix(outliner): move consecutive blocks in page order across parents - #13605
yuxi-liu-wired wants to merge 2 commits into
Conversation
| (and (not non-consecutive?) b (not same-parent?) (de/entity? a) | ||
| (= (:db/id (:block/page a)) (:db/id (:block/page b)))) | ||
| (ldb/sort-page-random-blocks (.-db a) top-level-blocks) |
There was a problem hiding this comment.
🔴 Property values disappear from consecutive selections
When a property value and its parent's next sibling are selected, get-top-level-blocks drops the property value. sort-page-random-blocks excludes property-created blocks, so moves and deletes process only the sibling.
Learn more
The page-order sorter builds a path from each block to its page. It returns no path for blocks with :logseq.property/created-from-property or :block/closed-value-property, and keep removes them from its result in block-order-path and sort-page-random-blocks. get-non-consecutive-blocks can nevertheless classify a last property child and its parent's next sibling as consecutive. The changed branch then sends both through the sorter. move-blocks and delete-blocks use its reduced selection, omitting the property child.
Example: On a page with A (whose last child is property value V) followed by B, select V and B and move them under C. The sorted selection contains B alone; V remains under A. Deleting that selection likewise leaves V behind.
Recommended fix: Do not pass property-created or closed-value blocks through sort-page-random-blocks unless it can return every selected block in the required order. Handle mixed page-order selections without dropping entries, and add move/delete tests for a last property child followed by its parent's next sibling.
Was this helpful? React with 👍 or 👎 to provide feedback.
get-top-level-blocks decided a consecutive selection was reversed by comparing the :block/order of its first 2 blocks. Order values are comparable only between siblings, but a last child and the block after its parent count as consecutive too; for those 2 the values are unrelated, and a move could reverse them (db-test logseq#1297: after an undo re-orders the second block, the redo moves it first). When the first 2 blocks have different parents on the same page, the selection is put in page order with ldb/sort-page-random-blocks.
The page-order sort leaves out blocks with no page-order path, so a property value selected with its parent's next sibling dropped out of the move or delete. Such selections keep their order unsorted.
e5a4671 to
624e017
Compare
|
Combined with the other PRs that change the same files into #13783. |
Fixes logseq/db-test#1297.
Moving a last child together with the block after its parent can reverse the 2. On a page with a, b (children b1, b2), c: Ctrl+click b2, then c, move them into a block elsewhere, undo twice and redo twice; the target holds c, b2.
get-top-level-blocksindeps/outliner/src/logseq/outliner/core.cljsdecides that a consecutive selection is reversed by comparing the:block/orderof its first 2 blocks. Order values are comparable only between siblings, but a last child and the block after its parent count as consecutive too (consecutive-block?), and their values are unrelated. In the steps above b2 has "b9R" and c "b9S"; undoing the move gives c "b9Q", so the redo compares "b9R" with "b9Q" and moves c first.When the first 2 blocks have different parents on the same page, the selection is now put in page order with
ldb/sort-page-random-blocks, the function the non-consecutive case already uses. Blocks with the same parent are compared by:block/orderas before. A selection holding a property value block is left unsorted, as on master: the page-order sort has no path for such a block and would leave it out of the move (a second commit, from review).New test
test-move-last-child-and-next-block-keeps-page-order: it gives the last child an order greater than the next block's and moves both; it fails on master (the target holds 5, 4) and passes with the change.test-move-property-value-and-next-block-keeps-both: a property value that is the last child, with the block after its parent; both move (the first commit alone moved only the second).frontend.modules.outliner.core-test(with its ^:long random tests),frontend.worker.undo-redo-test,frontend.worker.outliner-undo-property-testandfrontend.handler.editor-testpass.