Skip to content

fix: set operation.shape before computing initial transform in Feedback plugin#1988

Open
clauderic wants to merge 2 commits intomainfrom
fix/issue-1986-shape-null-first-modifier-call
Open

fix: set operation.shape before computing initial transform in Feedback plugin#1988
clauderic wants to merge 2 commits intomainfrom
fix/issue-1986-shape-null-first-modifier-call

Conversation

@clauderic
Copy link
Copy Markdown
Owner

Fixes #1986

Root cause

In Feedback.ts, the initial transform was computed (line 313) before the feedback element's shape was measured and set on dragOperation (lines 391–392). This meant that on the very first call to modifier.apply(), operation.shape was always null.

The ordering was:

  1. feedbackElement.setAttribute(ATTRIBUTE, 'true') — gives element position: fixed
  2. dragOperation.transform read → modifiers called with shape = null
  3. styles.set(...) — positions the feedback element correctly
  4. placeholder setup, popover promotion, observers
  5. const initialShape = new DOMRectangle(feedbackElement)dragOperation.shape = initialShape

Fix

Reorder so styles are applied first, then shape is measured and set, then the transform is computed:

  1. styles.set(...) with initialTranslate (no drag-transform offset yet)
  2. placeholder setup, popover promotion, observers (unchanged)
  3. const initialShape = new DOMRectangle(feedbackElement)dragOperation.shape = initialShape
  4. dragOperation.transform read → modifiers now have shape.initial
  5. styles.set({ translate }) — update translate with the modifier-adjusted value

On the first frame position.delta is {x:0,y:0}, so for modifiers that don't use shape the second styles.set is a no-op. For shape-dependent modifiers (snap-to-cursor etc.) it correctly applies the adjusted translation.

This restores the v1 behaviour where draggingNodeRect was always populated when a modifier ran.

Test plan

  • Create a snap-to-cursor modifier that reads operation.shape?.initial — verify the rect is non-null on the first frame
  • Verify existing drag behaviour (no modifier, SnapModifier, BoundingRectangle modifier) is unchanged
  • Test with and without DragOverlay

Automated fix by Claude Code

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 2, 2026

🦋 Changeset detected

Latest commit: 8a8f19c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@dnd-kit/dom Patch
@dnd-kit/abstract Patch
@dnd-kit/collision Patch
@dnd-kit/geometry Patch
@dnd-kit/helpers Patch
@dnd-kit/react Patch
@dnd-kit/state Patch
@dnd-kit/vue Patch
@dnd-kit/solid Patch
@dnd-kit/svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 2, 2026

Open in StackBlitz

@dnd-kit/abstract

npm i https://pkg.pr.new/@dnd-kit/abstract@1988

@dnd-kit/collision

npm i https://pkg.pr.new/@dnd-kit/collision@1988

@dnd-kit/dom

npm i https://pkg.pr.new/@dnd-kit/dom@1988

@dnd-kit/geometry

npm i https://pkg.pr.new/@dnd-kit/geometry@1988

@dnd-kit/helpers

npm i https://pkg.pr.new/@dnd-kit/helpers@1988

@dnd-kit/react

npm i https://pkg.pr.new/@dnd-kit/react@1988

@dnd-kit/solid

npm i https://pkg.pr.new/@dnd-kit/solid@1988

@dnd-kit/state

npm i https://pkg.pr.new/@dnd-kit/state@1988

@dnd-kit/svelte

npm i https://pkg.pr.new/@dnd-kit/svelte@1988

@dnd-kit/vue

npm i https://pkg.pr.new/@dnd-kit/vue@1988

commit: 8a8f19c

…ck plugin (closes #1986)

Add e2e tests for modifiers (vertical axis, horizontal axis, restrict to window, snap to grid).
Copy link
Copy Markdown
Owner Author

@clauderic clauderic left a comment

Choose a reason for hiding this comment

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

❌ Broken animation on multiple lists keyboard sorting

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.

Operation.shape is null on first modifier.apply() call

1 participant