Skip to content

feat(data-weaver): Snap atlas cards to grid after drag and resize - #448

Merged
beets merged 4 commits into
datacommonsorg:mainfrom
pablonoel:ui-snap_to_grid
Aug 25, 2026
Merged

feat(data-weaver): Snap atlas cards to grid after drag and resize#448
beets merged 4 commits into
datacommonsorg:mainfrom
pablonoel:ui-snap_to_grid

Conversation

@pablonoel

@pablonoel pablonoel commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

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

  • Unit tests passed
  • Integration tests passed
  • Manual verification

Checklist

  • I have followed the style guidelines of this project.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings.

Note: Only Maintainers can approve and merge PRs. Expected initial review time: 3 business days.

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread dataweaver/apps/web/src/components/scopes/atlas/shapes/card.tsx Outdated
Comment thread dataweaver/apps/web/src/hooks/use_shape_drag_handle.ts Outdated
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
pablonoel marked this pull request as ready for review August 25, 2026 17:24
@pablonoel pablonoel changed the title Snap atlas cards to grid after drag and resize feat(data-weaver): Snap atlas cards to grid after drag and resize Aug 25, 2026

@beets beets left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice -- thanks!

@beets
beets merged commit eb69119 into datacommonsorg:main Aug 25, 2026
8 checks passed
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.

2 participants