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

Item gets copied when it shouldn't when limiting "should-accept-drop" #43

Open
martinval opened this issue Sep 22, 2018 · 2 comments
Open

Comments

@martinval
Copy link

martinval commented Sep 22, 2018

Hi and thanks for this nice package,

I try to set up logic whereby a container does not accept a new list item if it has only 1 element in it.

The "should-accept-drop" function achieves this, but also produces the following bug:
If I want to take the last item out, it makes a copy, rather than emptying the container.

pls see here: codesandbox.io/s/wkpzqk4mmk

The use case I have is: A user fills a number of empty containers from a populated list. He can only put 1 item in the container, but he can also take it out and put another item in. (It's for a field mapping project where you allocate table columns to a template...)

@zerosym
Copy link

zerosym commented Sep 22, 2018

When a container has only a single item left, your shouldAcceptDrop function returns false for it, even if it is the source of the draggable item. onDrop doesn't get fired then for the source container, and consequently no applyDrag to remove the item from the container occurs.

See this updated sandbox for a fix
https://codesandbox.io/s/2v0k5q122n

@martinval
Copy link
Author

Great :) works like a charm, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants