feat(data-weaver): Snap atlas cards to grid after drag and resize - #448
Merged
Conversation
Adds a shared grid snap size and helper for atlas cards, then snaps their final x/y and size on drag/resize completion. This keeps cards aligned to the visible background grid while preserving freeform motion during the interaction itself. The custom drag-handle path now snaps explicitly as well, since it updates shapes directly instead of going through TLDraw's translate lifecycle.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces grid snapping functionality for cards upon completing a drag or resize action. It defines a GRID_SIZE constant, a snapToGrid helper, and implements snapping in ShapeCardUtil's onTranslateEnd and onResizeEnd hooks, as well as in the custom drag handle hook useShapeDragHandle. The review feedback recommends conditionally omitting height snapping for chart cards to prevent layout conflicts with auto-height management, and adding a movement check in useShapeDragHandle to prevent cards from jumping on a simple click.
Chart cards auto-size their height after resize, so snapping h again caused visible flicker. This commit skips the height snap for chart cards during resize completion and avoids snapping positions for plain click drags with no movement, preventing off-grid cards from jumping when the handle is pressed without dragging.
pablonoel
marked this pull request as ready for review
August 25, 2026 17:24
pablonoel
requested review from
beets,
miss-o-soup and
nick-nlb
as code owners
August 25, 2026 17:24
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.
Overview
Adds a shared grid snap size and helper for atlas cards, then snaps their final x/y and size on drag/resize completion. This keeps cards aligned to the visible background grid while preserving freeform motion during the interaction itself. The custom drag-handle path now snaps explicitly as well, since it updates shapes directly instead of going through TLDraw's translate lifecycle.
Testing Done
Describe the steps you took to test these changes (please also list commands ran if possible).
Checklist
Note: Only Maintainers can approve and merge PRs. Expected initial review time: 3 business days.