Skip to content

fix(editor): scroll a moved block into view after it moves - #13598

Closed
yuxi-liu-wired wants to merge 2 commits into
logseq:masterfrom
yuxi-liu-wired:fix/move-down-scroll
Closed

yuxi-liu-wired wants to merge 2 commits into
logseq:masterfrom
yuxi-liu-wired:fix/move-down-scroll

Conversation

@yuxi-liu-wired

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

Copy link
Copy Markdown
Contributor

Moving a block with Shift+Alt+Down past the bottom edge of the window leaves it below the edge: the page does not follow it. Each further press moves it further out of view, so the press looks like it did nothing. Shift+Alt+Up at the top edge follows the block.

The move scrolled the block into view before the move was applied, at the block's old place, which was still on screen, so the scroll did nothing. Up worked only because the block's old place at the top edge was already partly off screen.

The scroll now runs once the move is applied and the block is drawn in its new place.

From review, a second commit: the scroll runs only if the graph and route are still the ones the move started in (a page left during the move is not scrolled), and it scrolls the block's row in the view it was moved in, not a copy of it drawn first in an embed or the sidebar. Tests: moved-row-is-taken-in-the-view-it-moved-in-test, move-scroll-context-is-the-graph-and-route-test.

Before, on master, a 40-block journal with block 20 at the bottom edge of the window, 4 presses of Shift+Alt+Down: the block's top ends 86 px below the window's bottom edge, the page never scrolls. After: the page scrolls with every press and the block stays on screen. Held down (10 presses, 33 ms apart): before, 254 px below the edge; after, on screen. Up at the top edge, moves in the middle of the page, and blocks with children move as before.

yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 5, 2026

@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.

Devin Review

Comment thread src/main/frontend/handler/editor.cljs Outdated
Comment on lines +1828 to +1831
(js/requestAnimationFrame
(fn []
(when-let [block-node (util/get-first-block-by-id (:block/uuid (first blocks)))]
(.scrollIntoView block-node #js {:behavior "smooth" :block "nearest"}))))

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.

🟡 Delayed move scroll jumps to another view

If navigation finishes before requestAnimationFrame, the callback can scroll a sidebar copy of the moved block. The move's original page is no longer active, so the sidebar jumps unexpectedly.

Learn more

A move submits an asynchronous worker mutation. The transaction captures the original route, but the scroll callback looks up a block globally after the worker resolves. If the user navigates away before that callback and the block is also displayed in the sidebar, the lookup can find the sidebar copy and scroll it. The existing apply-outliner-ops checks the request route for editor callbacks, but this scroll has no equivalent guard.

Example: A user moves block A on its page, where A is also open in the sidebar. They navigate to another page before the move returns. The scheduled frame finds A in the sidebar and scrolls that sidebar unexpectedly.

Recommended fix: Capture the active graph and route when move-up-down starts. Before scrolling, verify they still match and locate the block inside its original view rather than with a document-wide first match.

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 8, 2026
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
Moving a block with Shift+Alt+Down past the bottom edge of the window
left it below the edge: the move scrolled the block into view before
the move was applied, at the block's old place, which was still on
screen. Moving up worked by luck: the block's old place at the top
edge was already partly off screen.

Scroll once the move is applied and the block is drawn in its new
place.
The scroll ran on the next frame after the move, whatever page was open
by then, on the block's first row in the document, which can be a copy
in an embed or the sidebar. It now runs only if the graph and route are
unchanged, on the row in the container the block was moved in.
@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

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

@yuxi-liu-wired
yuxi-liu-wired deleted the fix/move-down-scroll 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.

1 participant