Skip to content

fix(editor): don't snap dragged frames to their children's old positions - #12166

Open
SwastikTripathi wants to merge 1 commit into
excalidraw:masterfrom
SwastikTripathi:fix/frame-drag-ghost-snap
Open

SwastikTripathi wants to merge 1 commit into
excalidraw:masterfrom
SwastikTripathi:fix/frame-drag-ghost-snap

Conversation

@SwastikTripathi

@SwastikTripathi SwastikTripathi commented Sep 25, 2026 •

Copy link
Copy Markdown

Fixes #10480.

When you drag a frame, snapping excluded only the selected elements from the reference set. The frame's children move with it (dragSelectedElements handles them), but they stayed in the snap cache at their pre-drag positions. So the frame snapped to "ghost" edges and points where its children used to be, as in the issue's video.

The drag handler now caches reference points and visible gaps with includeElementsInFrames: true, so frame children are left out while their frame is being dragged. I made the change only in the drag path: resizing a frame doesn't move its children, so they're still valid snap targets there.

Tests: I added tests/snapping.test.tsx:

  • dragging a frame to 3px from its child's original corner doesn't snap and draws no snap lines. This test fails on master: the frame snaps to (50, 50) with 2 snap lines.
  • dragging a frame near an unrelated element still snaps to it.

yarn test:typecheck and the full vitest suite (138 files) pass.

@vercel

vercel Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
excalidraw Ready Ready Preview Oct 11, 2026 2:38am UTC

Request Review

@SwastikTripathi

Copy link
Copy Markdown
Author

Friendly ping, is there anything you'd like me to change in this PR? Happy to adjust.

When dragging a frame, only the frame itself was excluded from the snap
reference elements, but its children move along with it. The children
stayed in the reference set at their pre-drag positions, so the frame
snapped to "ghost" edges and points. Exclude frame children when
caching reference points and gaps for a drag.

Fixes excalidraw#10480

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@SwastikTripathi

Copy link
Copy Markdown
Author

Rebased onto master: #12258 moved this drag path out of App.tsx into App.selectionTool.ts, so the change now sits there. Same fix, tests still pass and the first one still fails without it.

This branch was successfully deployed

1 active deployment
Preview – excalidraw — f336fac3 Deployed Oct 11, 2026 by vercel[bot]
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.

frame snapping with non existing objects

1 participant