Skip to content

Preserve the grab point when dragging a node out of a Merge row - #4998

Closed
mvanhorn wants to merge 1 commit into
GraphiteEditor:masterfrom
mvanhorn:fix/4978-merge-row-grab-point
Closed

mvanhorn wants to merge 1 commit into
GraphiteEditor:masterfrom
mvanhorn:fix/4978-merge-row-grab-point

Conversation

@mvanhorn

Copy link
Copy Markdown

Why

After a sideways drag along a Merge row, pulling the node out of the row leaves the cursor to one side of the original grab point. That offset persists as the drag continues.

The drag handler counts horizontal grid movement even while the row constrains the node’s position. Once the node detaches, the handler applies only subsequent movement, so the node never catches up with the cursor.

What changed

The drag handler records the grabbed chain node and its starting x coordinate. Once the node detaches and the queued grid shifts finish, it applies the remaining horizontal displacement once and refreshes the node and wire positions. Alt-drag duplication clears the saved grab so the correction cannot move the original node. A regression test covers detachment in both directions, a straight vertical drag, an unchained node, and cancellation.

Testing

cargo test -q --manifest-path editor/Cargo.toml -p graphite-editor stopped before running tests because the editor requires rustc 1.98 and the installed version was 1.97.1. A run with the Graphite NodeGraphMessageHandler change reverted gave no clear result, so no test is shown to catch this bug.

Fixes #4978

AI was used for assistance.

The drag handler records the grabbed chain node and its starting x
coordinate. Once the node detaches and the queued grid shifts finish, it
applies the remaining horizontal displacement once and refreshes the
node and wire positions. Alt-drag duplication clears the saved grab so
the correction cannot move the original node. A regression test covers
detachment in both directions, a straight vertical drag, an unchained
node, and cancellation.

Fixes GraphiteEditor#4978
@github-actions

Copy link
Copy Markdown

This PR's title needs revising to follow the project's conventions:

  • Node names should be in single quotes, like 'Combine Paths'.
  • As a bug fix, it should usually begin with "Fix", followed by the broken behavior or by what was broken and how it now behaves.

Suggested titles:

Fix nodes dragged out of a 'Merge' row drifting away from the cursor's grab point
Fix the grab point shifting when dragging a node out of a 'Merge' row
Fix dragging a node out of a 'Merge' row so it stays under the cursor

Editing the title reviews it again.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@TrueDoctor

Copy link
Copy Markdown
Member

This should now be fixed, can you confirm by checking https://dev.graphite.art ?

@mvanhorn

Copy link
Copy Markdown
Author

Closing this: superseded by #5007. Happy to port the work if you still want it.

@mvanhorn mvanhorn closed this Nov 23, 2026
@TrueDoctor

Copy link
Copy Markdown
Member

@mvanhorn thanks for the pr, but I don't think this should be necassary any more since I changed how the snapping / movement works such that we compute the layout for every drag frame as a pure function from the initial state + drag offset so we should never get a situation where this issue could even occur since the drag history does not influence the layout

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.

Node loses its grab point when dragged out of a Merge layer

2 participants