Skip to content

fix(graph): 支持关闭网格自动吸附#5080

Open
ytzry wants to merge 2 commits into
antvis:masterfrom
ytzry:fix-issue-5071
Open

fix(graph): 支持关闭网格自动吸附#5080
ytzry wants to merge 2 commits into
antvis:masterfrom
ytzry:fix-issue-5071

Conversation

@ytzry

@ytzry ytzry commented Jun 8, 2026

Copy link
Copy Markdown

What is changed

  • Add snapToGrid support to grid options.
  • Allow grid rendering config and snap behavior config to be controlled independently.
  • Make graph coordinate snapping, node dragging, DnD drop, and transform resize respect the snap config.
  • Keep compatibility with existing minimal grid config such as { size: 10 }.
  • Add regression tests for config behavior and runtime interaction paths.

Tests

  • pnpm exec vitest run __tests__\graph\graph.spec.ts __tests__\graph\coord.spec.ts __tests__\view\node\index.spec.ts __tests__\plugin\dnd.spec.ts __tests__\plugin\transform.spec.ts
  • pnpm exec tsc --noEmit

@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 support for disabling automatic grid snapping via a new grid.snapToGrid option, updating the coordinate manager, drag-and-drop plugin, transform plugin, and node view to respect this setting. However, a bug was identified in the drag-and-drop plugin (src/plugin/dnd/index.ts) where the logic for shouldSnapToGrid incorrectly snaps the node to the grid when this.snapOffset is truthy, which would override and break snapline alignment. A correction has been suggested to ensure grid snapping is only applied when this.snapOffset is falsy.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/plugin/dnd/index.ts
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.

1 participant