fix: prevent scroll jump after block drag-and-drop#94
Merged
Conversation
Disable Tauri's native drag-drop handler via WebviewWindowBuilder::disable_drag_drop_handler() so HTML5 D&D events reach the BlockNote editor unintercepted. Add a DOM-level scroll guard in the cursor-centering ProseMirror plugin that captures scrollTop at drag-start and aggressively restores it after drop, preventing the browser from jumping to the old cursor position when blocks are moved across distant parts of the document. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the block drag-and-drop behavior that was broken after PR #88 (window restore feature):
D&D not working at all: Tauri's native drag-drop handler was intercepting HTML5 D&D events. Fixed by calling
WebviewWindowBuilder::disable_drag_drop_handler()during programmatic window creation.Scroll jump after drop: After dropping a block, the viewport jumped to the old cursor position. Root cause: during drag, ProseMirror/BlockNote internally scrolls to the selection, changing
scrollTop. Fixed by capturingscrollTopatdragstartand aggressively restoring it afterdropusing a 500ms guard window with multiple restoration attempts and a scroll event interceptor.Changes
src-tauri/src/window.rs.disable_drag_drop_handler()to WebviewWindowBuildersrc/features/editor/lib/cursorCentering.tssrc/features/editor/lib/cursorCenteringConfig.tsTesting
tsc --noEmitpassesbiome ci .passescargo buildpasses