feat: add snap-to-grid toggle to workflow canvas#2925
feat: add snap-to-grid toggle to workflow canvas#2925AleksandarCole merged 5 commits intosuperplanehq:mainfrom
Conversation
Signed-off-by: prudh-vi <lovelyprudhvi3105@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
|
@prudh-vi looks great 🎉 Assigning @AleksandarCole to review the functionality. |
|
Hey @prudh-vi this works great! Thanks for taking this. Also, can we make an update so that by default this snap to grid is turned on? |
|
Sure I can do that @AleksandarCole |
Signed-off-by: prudh-vi <lovelyprudhvi3105@gmail.com>
|
@AleksandarCole I have changed the grid to 48 from 16 and also by default the snap to grid is turned on. |
8578b90 to
7ae1a75
Compare
|
@prudh-vi awesome! Seems like CI format check is failing though: https://superplanehq.semaphoreci.com/jobs/c60d7b85-ab87-43f7-8f31-5a6d45226169 |
|
Sure @AleksandarCole |
Signed-off-by: prudh-vi <lovelyprudhvi3105@gmail.com>
7ae1a75 to
23371db
Compare
|
Merging this. Thank you for contributing @prudh-vi ⭐ |
## Summary This PR adds a snap-to-grid toggle feature to the workflow canvas as described in superplanehq#2813 ## Changes ### Canvas Integration (`app/web/src/ui/CanvasPage/index.tsx`) * Added `isSnapToGridEnabled` state to track grid snapping status * Passed `snapToGrid={isSnapToGridEnabled}` and `snapGrid={[16, 16]}` props to ReactFlow component * Grid spacing set to 16x16 pixels for consistent alignment ```tsx const [isSnapToGridEnabled, setIsSnapToGridEnabled] = useState(false); <ReactFlow snapToGrid={isSnapToGridEnabled} snapGrid={[16, 16]} // ... other props /> ``` ### UI Components (`app/web/src/components/zoom-slider.tsx`) * Added grid toggle button to the ZoomSlider toolbar (bottom-left) * Uses `Grid3X3` icon from lucide-react * Button variant changes based on state (default when enabled, ghost when disabled) * Added tooltip: "Enable/Disable snap to grid" for user guidance ```tsx <Tooltip> <TooltipTrigger asChild> <Button variant={isSnapToGridEnabled ? "default" : "ghost"} size="icon-sm" onClick={() => setIsSnapToGridEnabled(!isSnapToGridEnabled)} > <Grid3X3 className="h-3 w-3" /> </Button> </TooltipTrigger> <TooltipContent> {isSnapToGridEnabled ? "Disable snap to grid" : "Enable snap to grid"} </TooltipContent> </Tooltip> ``` ### Functionality * **Toggle OFF (default)**: Nodes can be placed at any pixel position (free-form) * **Toggle ON**: Nodes automatically snap to nearest 16px grid intersection * Preserves all existing canvas functionality (zoom, pan, selection, etc.) ## Testing * ✅ Verified free-form placement when toggle is disabled * ✅ Verified nodes snap to 16px grid systematically when toggle is enabled * ✅ Toggle works smoothly without affecting other canvas operations * ✅ No console errors or visual glitches ## Before https://github.com/user-attachments/assets/e277cc8f-c894-4f4c-aa65-9c963ba3bda5 ## After https://github.com/user-attachments/assets/52fa0689-59cd-4c34-8ece-e304cac19b71 --------- Signed-off-by: prudh-vi <lovelyprudhvi3105@gmail.com> Signed-off-by: Muhammad Fuzail Zubari <mfuzail.zubari@gmail.com>
Summary
This PR adds a snap-to-grid toggle feature to the workflow canvas as described in #2813
Changes
Canvas Integration (
app/web/src/ui/CanvasPage/index.tsx)isSnapToGridEnabledstate to track grid snapping statussnapToGrid={isSnapToGridEnabled}andsnapGrid={[16, 16]}props to ReactFlow componentUI Components (
app/web/src/components/zoom-slider.tsx)Grid3X3icon from lucide-reactFunctionality
Testing
Before
Before.Video.mov
After
After.Video.mov