Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When changing DragOverlay width or height, dnd keeps it on a wrong place using handle #1588

Open
bohumilmilacek opened this issue Jan 12, 2025 · 2 comments

Comments

@bohumilmilacek
Copy link


name: Bug Report
about: DragOverlay unexpected behaviour when size changed.
labels: bug

Description

When width or height is edited in DragOverlay(Example 1 below). The overlay is kept far away from the dnd handle. So when I try to modify the overlay position, it keeps the overlay collision box on the original box(Example 2). Does anybody know how to fix this?

Example 1

<DragOverlay
   modifiers={[restrictToFirstScrollableAncestor]}
   style={{
      width: 126,
      height: 126,
   }}
>
</DragOverlay>
Screen.Recording.2025-01-12.at.9.45.35.mov

Example 2

<DragOverlay
   modifiers={[restrictToFirstScrollableAncestor, cursorOffsetModifier]}
   style={{
      width: 126,
      height: 126,
   }}
>
</DragOverlay>

const cursorOffsetModifier: Modifier = ({ transform, activeNodeRect, overlayNodeRect }) => {
   if (!activeNodeRect || !overlayNodeRect) return transform;
   return {
      ...transform,
      x: transform.x + activeNodeRect.width - overlayNodeRect.width,
      y: transform.y, // Keep Y unchanged
   };
};
Screen.Recording.2025-01-12.at.9.46.12.mov

Expected Behavior

I expect the DragOverlay to be on the handle, even when I change the size.

Actual Behavior

The overlay is on the previous position like if the size of the DragOverlay wasn't changed.

Environment

MacOS Seqouia 15
Chrome 131
React 19
Typescript 5

@oolongstack
Copy link

I felt like it at first https://docs.dndkit.com/api-documentation/draggable/drag-overlay#portals, but it seems not.

@bohumilmilacek
Copy link
Author

I felt like it at first https://docs.dndkit.com/api-documentation/draggable/drag-overlay#portals, but it seems not.

I tried the portal, but it did not help me. Should that solve the problem?

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

No branches or pull requests

2 participants