Skip to content

feat: add snap-to-grid toggle to workflow canvas#2925

Merged
AleksandarCole merged 5 commits intosuperplanehq:mainfrom
prudh-vi:feat/snap-to-grid
Feb 10, 2026
Merged

feat: add snap-to-grid toggle to workflow canvas#2925
AleksandarCole merged 5 commits intosuperplanehq:mainfrom
prudh-vi:feat/snap-to-grid

Conversation

@prudh-vi
Copy link
Contributor

@prudh-vi prudh-vi commented Feb 7, 2026

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)

  • 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
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
<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

Before.Video.mov

After

After.Video.mov

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

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.

@shiroyasha shiroyasha added the pr:stage-2/3 Needs to pass functional review label Feb 8, 2026
@shiroyasha
Copy link
Collaborator

@prudh-vi looks great 🎉 Assigning @AleksandarCole to review the functionality.

@AleksandarCole AleksandarCole added bounty This issue has a bounty open and removed bounty This issue has a bounty open labels Feb 8, 2026
@AleksandarCole
Copy link
Collaborator

Hey @prudh-vi this works great! Thanks for taking this.
Do you think we can make few changes? Now that I see it in action, I think we should set the grid to 48 instead of 16.

Also, can we make an update so that by default this snap to grid is turned on?

@prudh-vi
Copy link
Contributor Author

prudh-vi commented Feb 9, 2026

Sure I can do that @AleksandarCole

Signed-off-by: prudh-vi <lovelyprudhvi3105@gmail.com>
@prudh-vi
Copy link
Contributor Author

@AleksandarCole I have changed the grid to 48 from 16 and also by default the snap to grid is turned on.

@AleksandarCole
Copy link
Collaborator

@prudh-vi awesome! Seems like CI format check is failing though: https://superplanehq.semaphoreci.com/jobs/c60d7b85-ab87-43f7-8f31-5a6d45226169
Can you try to fix this, and then we can merge.

@prudh-vi
Copy link
Contributor Author

prudh-vi commented Feb 10, 2026

Sure @AleksandarCole

Signed-off-by: prudh-vi <lovelyprudhvi3105@gmail.com>
@AleksandarCole
Copy link
Collaborator

Merging this. Thank you for contributing @prudh-vi

@AleksandarCole AleksandarCole merged commit f4770d6 into superplanehq:main Feb 10, 2026
4 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in SuperPlane Board Feb 10, 2026
mfuzailzubari pushed a commit to mfuzailzubari/superplane that referenced this pull request Feb 19, 2026
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:stage-2/3 Needs to pass functional review

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants