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

Add support for canDrop prop ala react-dnd #1139

Closed
mateja176 opened this issue Feb 12, 2020 · 3 comments
Closed

Add support for canDrop prop ala react-dnd #1139

mateja176 opened this issue Feb 12, 2020 · 3 comments
Labels
stale The label to apply when a pull request or an issue is stale

Comments

@mateja176
Copy link

Use it to specify whether the drop target is able to accept the item. If you want to always allow it, just omit this method. Specifying it is handy if you'd like to disable dropping based on some predicate over propsor monitor.getItem(). Note: You may not call monitor.canDrop()inside this method.

Source react-dnd

@mateja176
Copy link
Author

mateja176 commented Feb 12, 2020

One workaround is to determine if a drop is allowed in retrospective, in onDragStop so that you undo a drop which should not be allowed. This is far from optimal, hence I'd love to hear more ideas.

EDIT even taking suggestions from #382 into account I wasn't to programatically update the layout. Hence I resorted to extreme measures, more precisely, I reinstantiated the component to force it to render with the updated layout (the kind of thing which happens to you if you accidentally pass an inline function as the component prop of a Route from react-router-dom).

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 7 days

@github-actions github-actions bot added the stale The label to apply when a pull request or an issue is stale label Mar 14, 2020
@pohsiu
Copy link

pohsiu commented Apr 15, 2020

@mateja176 would you mind to share your solution about this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale The label to apply when a pull request or an issue is stale
Projects
None yet
Development

No branches or pull requests

2 participants