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

Drag and Drop positions draggable element incorrectly when style.margin-left is set #16171

Closed
shershey opened this issue May 31, 2019 · 1 comment · Fixed by #16180
Closed
Assignees
Labels
G This is is related to a Google internal issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@shershey
Copy link

Reproduction

The following stackblitz demonstrated the problem:

https://stackblitz.com/edit/angular-drag-and-drop-bug

Steps to reproduce:

  1. Copied https://material.angular.io/cdk/drag-drop/overview#reordering-lists to stackblitz
  2. Added marginLeft style to the draggable elements.

When using draggable elements outside of cdkDropList, the problem does not occur.

Expected Behavior

I was expecting that the dragged element would not jump suddenly to the right when I start dragging.

Actual Behavior

The dragged element jumps to the right.

In looking at this line, it appears that the style is copied from the draggable element when creating the preview element. That in combination with the transform applies the marign-left twice (sort of). I was hoping that maybe I could work around this by using cdkDragFreeDragPosition instead of setting marginLeft, but it seems cdkDragFreeDragPosition doesn't work when used inside cdkDropList. This bug seems to be similar to #13107 but I believe that bug is closed and the fix does not seem to help here.

I'd love to know if there are ways I can work around this bug for now.

Environment

@jelbourn jelbourn added the G This is is related to a Google internal issue label May 31, 2019
@crisbeto crisbeto added has pr P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Jun 2, 2019
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 2, 2019
…m has margin

Fixes the preview shifting sideways relative to the cursor, if the item that's being dragged has a margin.

Fixes angular#16171.
jelbourn pushed a commit that referenced this issue Sep 6, 2019
…m has margin

Fixes the preview shifting sideways relative to the cursor, if the item that's being dragged has a margin.

Fixes #16171.
jelbourn pushed a commit that referenced this issue Sep 9, 2019
…m has margin (#16180)

Fixes the preview shifting sideways relative to the cursor, if the item that's being dragged has a margin.

Fixes #16171.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
G This is is related to a Google internal issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants