-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
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.
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. |
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? |
There might be a potential problem, currently when the item dragged out from a container the What do you think? |
Hi, |
@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. |
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? |
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. |
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 |
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 |
@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. |
Thanks @devversion , Here's the complete log: bazel run //tools/public_api_guard:cdk_drag-drop_api.accept Any suggestion how to proceed? Thanks |
@TKul6 Thanks! Looks like Otherwise you should be able to just manually make changes as the |
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??? |
Thanks @devversion. The most critical changes are here and here the other stuff is just handling CI stuff. Thank you all |
Any news? Thanks! |
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 |
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? |
@TKul6 that does sound interesting. I was planning on having another service or moving some of the logic to the |
Great, thanks @crisbeto . Thanks a lot |
We appreciate the enthusiasm, but something like this would have to fit into the existing planned work for drag and drop. |
Sorry @crisbeto but I think I lost you. |
@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. |
Hi @crisbeto, |
@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. |
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 |
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
_updateActiveDropContainer
method I check if the item is still over the drop container, if it doesn't I assign the_initalContainer
to be the new drop container.