fix(editor): improve block drag-and-drop hit targeting#100
Merged
Conversation
Increase the dead zone from 4px to 16px so the drag handle appears more readily when hovering near a block. Add a nearest-block fallback so the cursor always resolves to a target during drag operations, even when positioned in the gap between blocks. Extract element lookup into getTopLevelBlockElements for reuse across the two search passes. Closes #99 Co-authored-by: Ona <no-reply@ona.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Author
|
✅ UI verification passed — design spec compliance confirmed. Static analysis —
Visual verification (Playwright screenshots of editor page):
Changes are logic-only (hit-testing improvements for drag-and-drop targeting) with no visual impact at rest. |
Collaborator
Author
|
✅ Post-merge verification passed. E2E suite: 27/27 tests passed (auth, editor drag-and-drop, editor links, slash commands, floating toolbar, page CRUD, sidebar drag-and-drop, workspace switcher). Ad-hoc smoke tests:
No routes skipped. |
This was referenced Apr 16, 2026
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.
Problem
Dragging blocks via the grip handle is finicky — the cursor must be positioned on the exact line of a block for the drop indicator to appear. Moving the cursor into the gap between blocks causes the target to vanish, making reordering unreliable.
Root cause
Two issues in
getBlockElement:mt-0.5), so the gaps between them are larger than 4px. The cursor frequently lands in "no man's land" where no block is matched.nullinstead of snapping to the nearest block. This causes the drop indicator to disappear and the drop to fail.Changes
HANDLE_DEAD_ZONEfrom 4px to 16px so the drag handle appears more readily when hovering near a blockDRAGOVER_COMMAND/DROP_COMMAND), always use unbounded search so the cursor always resolves to a targetgetTopLevelBlockElementshelper to avoid duplicating the element lookup across the two search passesCloses #99