Uh oh!
There was an error while loading. Please reload this page.
Cancel drag after hovering a drop zone - #13879
Conversation
Dragging an item over a drop zone and dropping it outside the zone cancels the drag.
Test a use case when the client drags an element over a drop zone and drop it outside the zone.
TKul6
commented
Oct 30, 2018
Hi @crisbeto, can you help with the CI, I'm not sure I understand the problem from the error. The entire tests suite passed locally... |
I don't think that this is the most common use case or the more intuitive behavior. When the user moved the item over to the new list, they already got some feedback that the item was transferred. Having it go back to a different one while also removing the placeholder from the current container looks confusing. |
TKul6
commented
Oct 30, 2018
Thanks for the comment @crisbeto,
I'm sorry but I do believe this scenario may happen (it happened to me several times). Now, according to the current implementation the drag process will not be canceled, but completed (even though the user dropped the item in an invalid zone), the user would have to take the item back to the initial drop zone by himself. Think of a use case that you have more than source drop zone and target drop zone, now the user must remember the source drop zone to drop the item back.
This is the use case I'm trying to solve, and I tried to implement a solution based on my experience with drag and drop cases as I mentioned earlier. What do you say? |
TKul6
commented
Oct 30, 2018
There might be a potential problem, currently when the item dragged out from a container the What do you think? |
Alex6015
commented
Oct 31, 2018
Hi, |
crisbeto
commented
Oct 31, 2018
@TKul6 I think that we should be able to support your case, but it shouldn't be the default behavior. I'm open to ideas about what the API could look like. |
TKul6
commented
Oct 31, 2018
OK, I agree it may change behavior in existing applications. If I understand the an Angular That way, when a drag item is created, it will have an LastContainer DropStrategy (the default behavior) and in my module / component I'll override the config with InitialContainer DropStrategy. So:
What do you say @crisbeto? |
TKul6
commented
Nov 2, 2018
Hi @crisbeto have you had a chance to consider my suggested solution? Thanks |
Adding to CDK_DRAG_CONFIG additional parameter to support cancel dropping in invalid drop zone.
Hi @TKul6! This PR has merge conflicts due to recent upstream merges. |
1 similar comment
Hi @TKul6! This PR has merge conflicts due to recent upstream merges. |
TKul6
commented
Dec 10, 2018
Hi @jelbourn can you please help me with the Bazel issue, I'm not sure what's the problem or how to handle it. Thanks, |
@TKul6 You need to have @jelbourn Since we didn't declare |
TKul6
commented
Dec 10, 2018
Thanks a lot @devversion, I have now Bazel working however I get this error while running: Do you have any suggestion how to investigate this issue? Thanks |
devversion
commented
Dec 10, 2018
@TKul6 That looks new to me. Can you send the whole log output? Might be worth clearing the cache using I will work on a markdown document for Bazel soon. This should make it more clear. |
TKul6
commented
Dec 10, 2018
Thanks @devversion , Here's the complete log: bazel run //tools/public_api_guard:cdk_drag-drop_api.accept Any suggestion how to proceed? Thanks |
devversion
commented
Dec 10, 2018
@TKul6 Thanks! Looks like Otherwise you should be able to just manually make changes as the |
TKul6
commented
Dec 11, 2018
Thanks @devversion, it seems closing some applications did the trick. However, now the e2e tests are failing, from the logs (in CircleCI) it seems the chrome version is wrong?: Is it related to ciecleCI, I saw the Selenium server is up and running, Is there anywhere in the project to control the chrome version??? |
devversion
commented
Dec 11, 2018
TKul6
commented
Dec 12, 2018
Thanks @devversion. The most critical changes are here and here the other stuff is just handling CI stuff. Thank you all |
Alex6015
commented
Dec 16, 2018
Any news? Thanks! |
TKul6
commented
Dec 16, 2018
crisbeto
commented
Dec 17, 2018
Sorry for the delayed response @TKul6. I think the problem with this approach is that we'd have to have the CDK know about all the possible strategies and have it react accordingly with the various combinations of it and the inputs. Wouldn't it be more flexible if we made the |
TKul6
commented
Dec 17, 2018
Hi @crisbeto , Maybe, since we change the behavior, but we still need 99% of the original drag class, we should extract the container update logic to external service that will be an optional injected service to the drag class. this way we keep one clean class and support for any kind of dropping strategy that might be needed in the future (just extend the service and override the method). And in this way the cdk doesn't need to know anything about strategy. It doesn't need to know even how to update the target container. All he knows there is some service he can query or invoke in order to get the updated container. What do you think? shell we continue with your approach or mine? |
crisbeto
commented
Dec 21, 2018
@TKul6 that does sound interesting. I was planning on having another service or moving some of the logic to the |
TKul6
commented
Dec 21, 2018
Great, thanks @crisbeto . Thanks a lot |
crisbeto
commented
Dec 21, 2018
We appreciate the enthusiasm, but something like this would have to fit into the existing planned work for drag and drop. |
TKul6
commented
Dec 22, 2018
Sorry @crisbeto but I think I lost you. |
crisbeto
commented
Dec 23, 2018
@TKul6 I'm afraid that you would end up wasting your time by doing it now since we'll have to move things around it in the future, in order to support more use cases that we have planned. |
TKul6
commented
Dec 29, 2018
Hi @crisbeto, |
leosun1221
commented
Jan 20, 2019
@TKul6 I have similar issue , I use isPointerOverContainer in cdkDropListDropped output to check if it is inside the drop area. |
Hey guys, is there any resolution about this? There is still no proper way of cancelling the dropping of an item. |
andrewseguin
commented
Jan 15, 2025
Unfortunately this PR is unlikely to land since too much had changed in the drag implementation for this code to be applicable. I opened #30333 to track this feature request. If anyone wants to open a new updated PR with this feature, we'd be happy to take contributions and give feedback |
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. |

I noticed that when a drag item being drag over a drop zone it is impossible to cancel the drag.
This stackblitz can demonstrate the problem:
https://stackblitz.com/angular/lmgeabvykokl
If you drag item from the To do list over the Done list and then drop it outside the done drop zone the item will land in the done zone.
This is not an expected behavior, if I dragged an item to a drop zone, but then drop it outside the drop zone, then the item should be returned to the initial container.
I think my fix is very straight forward: in the
_updateActiveDropContainermethod I check if the item is still over the drop container, if it doesn't I assign the_initalContainerto be the new drop container.