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

cdkDrag inside drop list doesn't preserve transform value #22407

Closed
anirudhvarma12 opened this issue Apr 6, 2021 · 4 comments · Fixed by #22422
Closed

cdkDrag inside drop list doesn't preserve transform value #22407

anirudhvarma12 opened this issue Apr 6, 2021 · 4 comments · Fixed by #22422
Assignees
Labels
area: cdk/drag-drop P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@anirudhvarma12
Copy link

anirudhvarma12 commented Apr 6, 2021

What are you trying to do?

I am trying to absolutely position draggable elements inside a drop container using transform. Something like -

<div [style.transform]="transformString" cdkDrag>...</div>

Before upgrading to cdk v9, this worked perfectly. However, after upgrading, it seems like the transform style is overwritten by the CDK.

What troubleshooting steps have you tried?

After some digging, it seems like this code is performing the reset.

I tried using cdkDragFreeDragPosition, but that only works in the absence of a drop container.

It also seems like this PR, should fix the issue?

Is there any other recommended way of setting this?

What are you seeing that does not match your expectations?

Reproduction

N/A

Environment

  • Angular: 9.1.4
  • CDK/Material: 9.2.4
  • Browser(s): Firefox
  • Operating System (e.g. Windows, macOS, Ubuntu): MacOS Catalina
@anirudhvarma12 anirudhvarma12 added needs triage This issue needs to be triaged by the team troubleshooting This issue is not reporting an issue, but just asking for help labels Apr 6, 2021
@crisbeto
Copy link
Member

crisbeto commented Apr 6, 2021

I don't think we ever had special handling for this so if it worked before, it was probably by accident. I definitely think that we should fix it, but #18145 isn't the way to go, because it only applies to drag items that are outside of a list. I think that the easiest workaround until we fix it on our end is to apply your transform on a child element inside the cdkDrag. E.g.

<div cdkDrag>
  <div style="transform: ..."></div>
</div>

@crisbeto crisbeto changed the title help(drag-drop): setting initial transform for fields inside drop containers cdkDrag inside drop list doesn't preserve transform value Apr 6, 2021
@crisbeto crisbeto added area: cdk/drag-drop P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team troubleshooting This issue is not reporting an issue, but just asking for help labels Apr 6, 2021
@anirudhvarma12
Copy link
Author

@crisbeto , yeah, I ended up doing something similar. Thanks!

@anirudhvarma12
Copy link
Author

@crisbeto , also, if you (or anyone) could give me some pointers, I would be interested in taking a shot at fixing it.

@crisbeto crisbeto self-assigned this Apr 7, 2021
@crisbeto crisbeto added the has pr label Apr 7, 2021
crisbeto added a commit to crisbeto/material2 that referenced this issue Apr 7, 2021
We have some logic that tries to preserve the original `transform` of an element, but we only apply it while dragging. These changes expand the support to include elements inside a drop list, as well as the preview and placeholder.

Fixes angular#22407.
mmalerba pushed a commit that referenced this issue Apr 13, 2021
We have some logic that tries to preserve the original `transform` of an element, but we only apply it while dragging. These changes expand the support to include elements inside a drop list, as well as the preview and placeholder.

Fixes #22407.
@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 May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: cdk/drag-drop 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.

2 participants