Skip to content

fix: prevent scroll jump after block drag-and-drop#94

Merged
j4rviscmd merged 2 commits intomainfrom
fix/fix-dnd-handle
Mar 28, 2026
Merged

fix: prevent scroll jump after block drag-and-drop#94
j4rviscmd merged 2 commits intomainfrom
fix/fix-dnd-handle

Conversation

@j4rviscmd
Copy link
Copy Markdown
Owner

Summary

Fix the block drag-and-drop behavior that was broken after PR #88 (window restore feature):

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

  2. 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 capturing scrollTop at dragstart and aggressively restoring it after drop using a 500ms guard window with multiple restoration attempts and a scroll event interceptor.

Changes

File Change
src-tauri/src/window.rs Add .disable_drag_drop_handler() to WebviewWindowBuilder
src/features/editor/lib/cursorCentering.ts Add DOM-level drag/drop scroll guard in ProseMirror plugin
src/features/editor/lib/cursorCenteringConfig.ts Add explicit type annotation

Testing

  • Cross-page block D&D: no scroll jump
  • Same-page block D&D: works correctly
  • Normal typing: cursor centering still works
  • TypeScript: tsc --noEmit passes
  • Lint: biome ci . passes
  • Rust: cargo build passes

j4rviscmd and others added 2 commits March 28, 2026 10:01
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>
@j4rviscmd j4rviscmd added the bug Something isn't working label Mar 28, 2026
@j4rviscmd j4rviscmd merged commit b901fb2 into main Mar 28, 2026
2 checks passed
@j4rviscmd j4rviscmd deleted the fix/fix-dnd-handle branch March 28, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant