-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(drag-drop): not picking up handle that isn't a direct descendant #13360
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
fix(drag-drop): not picking up handle that isn't a direct descendant #13360
Conversation
7c5ec03
to
07e9b8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Just needs rebase |
Hi @crisbeto! This PR has merge conflicts due to recent upstream merges. |
07e9b8d
to
ca8ce11
Compare
This one's good to go now. |
Fixes not being able to have a drag handle that isn't a direct descendant of `CdkDrag`. Fixes angular#13335.
ca8ce11
to
6074ff4
Compare
Hello @crisbeto I have an issue (stackblitz preview) that could be solved by the merging of this PR, just was curious if you all had an estimate of when this would go in since I see it's been good to go for 5 days. Thanks! |
Do the same thing apply to to CdkDrag in relation to CdkDropList i.e. can a CdkDropList parent have projected content containing CdrDrag (and CdkDragHandle)? |
Each |
Great but just to clarify, so there are no problem using a ngFor in a CdkDropList that loads the content through an ngTemplate ref (that containt the CdkDrag and CdkDragHandle? |
Having it in an |
FYI: This show the non-working scenario. |
It doesn't work because the <div cdkDropList class="example-list" (cdkDropListDropped)="drop($event)">
<ng-container *ngTemplateOutlet="content"></ng-container>
<ng-template #content>
<div class="example-box" *ngFor="let movie of movies" cdkDrag>
{{movie.title}}
</div>
</ng-template>
</div> |
This is not working: https://stackblitz.com/edit/material-handle-issue |
@shyamal890 that's not the case that is described here. There's no way for us to manage the one you posted, because one component can't "reach into" the template of another component in order to get a reference to the handle. |
So much for splitting up components then. |
#14437 will add a bit more flexibility. |
@crisbeto Does this mean we cannot currently have the cdkDropList in a parent component and the cdkDrag/cdkDragHandle in a child component? When I try this it doesn't work. If this isn't possible, will #14437 allow us to do this? |
It helped me, hope it helps you guys.
My drag handle was inside files-container-item component, which did NOT work.
Now INSIDE child files-container-item component where the old drag handle used to be I put:
What we did to make it work was to move dragHandle out of child component into parent with SLOT parameter, and in child component have ng-content with select a SLOT. |
this circumvents the cdk limitation described in: * angular/components#13360 * angular/components#13784
What's the current status on that ?
What's the status ? I need this too. In my dashboard component I have a list of widget configurations, each widget configuration is passed to a widget component, that component has a header, that header should be my handle. The cdkDropList is of course in the dashboard component attached to a div.row. The cdkDragHandle is on my header inside of the widget component. I think this is a common use case, and it's very unfortunate that right now the cdkDragHandle is ignored and no way around. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes not being able to have a drag handle that isn't a direct descendant of
CdkDrag
.Fixes #13335.