components icon indicating copy to clipboard operation
components copied to clipboard

fix(cdk/drag-drop): support for nested drop containers (#16671)

Open soren-petersen opened this issue 4 years ago • 9 comments
trafficstars

Fixes a two issues with nested drop containers. The first fixed issue is that the elements of cdkDropListConnectedTo previously had to be ordered correctly to support moving items into an inner drop container. Sepcifically, inner drop containers had to be listed before their outer ancestors. The second fixed issue is that items of an inner container could not be re-ordered without moving the item out of the container and then back in.

Fixes #16671

soren-petersen avatar Jan 09 '21 14:01 soren-petersen

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

google-cla[bot] avatar Jan 09 '21 14:01 google-cla[bot]

@googlebot I signed it!

soren-petersen avatar Jan 09 '21 14:01 soren-petersen

First of all, thank you for constructive feedback!

On top of the other comments, we definitely need some unit tests to ensure that things work as expected. It would be nice to have an example in the dev app as well so nested dragging can be tested manually.

With respect to unit tests and an example in the dev app, I'm sure I would be able to put something together. Unfortunately, I would need to spend quite a bit of time to figure out how it all works. At the moment, I have no idea where the dev-app is located, let alone how to add an example. Nor am I familiar with the unit test framework. Is there, perhaps, someone with more experience as a contributor who could support me with this?

soren-petersen avatar Jan 14 '21 20:01 soren-petersen

I wrote most of the drag-drop module so I can help with it. To run the dev app, you have to install the dependencies by running yarn and then yarn dev-app will start the server. As for the unit tests, you have to run yarn test drag-drop. The dev app for the drag-drop module is in src/dev-app/drag-drop/drag-drop-demo.ts and the unit tests are in src/cdk/drag-drop/directives/drag.spec.ts.

crisbeto avatar Jan 14 '21 20:01 crisbeto

Really excited to see this go in guys as it relates directly to a big requirement in my current project. Thank you for your work @soren-petersen and @crisbeto. Any ideas on what version of Material it might be expected in? It would be brilliant to start using it.

peternixey avatar Aug 20 '21 12:08 peternixey

@crisbeto So still nothing has been done to fix the issue "The second fixed issue is that items of an inner container could not be re-ordered without moving the item out of the container and then back in.". There is no workaround for this. I would like to suggest an alternative approach, as you wrote "I wrote most of the drag-drop module so I can help with it.". My suggestion is, that you just define a unit test yourself which verifies that the re-ordering can be done. This unit test will fail because it doesn't work and then you just correct the drag-drop module and afterwards the unit test will succeed. This problem has existed for years, wouldn't it be an idea to finally get it fixed? I don't know how your drag-drop module works, but I use it and it works fine in many regards, however not in this regard! Isn't it quite simple, if the user is dragging it over it's own droplist, and sorting is not turned off, it should be reordered, otherwise it should work as usual? By the way, I think it should rather be named re-ordering than sorting.

henrikdahl8240 avatar Oct 15 '21 10:10 henrikdahl8240

Is there any hope that this will ever be the solution? Or that there will be any kind of solution for this kind of feature? Should I try another approach? Any ideas?

diego-rapoport avatar Jun 19 '23 14:06 diego-rapoport

@crisbeto Can we please get this issue fixed, its been 3 years since people have been encountering this issue.

Would really appreciate if you could spare a little bit of your time to resolve this.

ankit9015 avatar Jun 21 '24 13:06 ankit9015

We have this issue too, can you resolve this issue ?

squelix avatar Sep 16 '24 08:09 squelix

Closing this particular PR since it has gotten out of sync with the repo and still needs tests added. We encourage anyone to reopen this PR with tests so we can get this merged in

andrewseguin avatar Jan 22 '25 19:01 andrewseguin

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.