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
monitor.isDragging() sometimes returns false when it should return true #227
Comments
@amoenk Yes, we will need example code to help you. |
Thanks for your help! Here's the working example: http://notlouieagain.com/~amoenk/dnd/ And this link to browse the unbundled code: http://notlouieagain.com/~amoenk/dnd/js/ Oh, I included the original simple sortable demo code in there too while I was debugging, but the important components are Ingredient and IngredientGroup. |
I had a look at your code and I can't seem to find |
Demo code removed, DnDStudy component is a page component here: http://notlouieagain.com/~amoenk/dnd/js/pages/DnDStudy.react.js |
Ok I had a look and I believe that it may be a problem due to keys of |
Code updated, but still same problem. |
Ok. I was wrong then. @gaearon can you help? |
For const ingredientSource = {
beginDrag(props) {
return { ingredient: props.ingredient };
},
isDragging(props, monitor) {
return props.ingredient === monitor.getItem().ingredient;
}
}; See
Does this help? |
Works perfectly! Must have missed that in the docs. Thanks for all your help! I'll close the ticket. |
No problem. Happy to help. |
A card can now navigate through several lists as well as empty list. A noticable thing is that I have to implement the isDragging function, it is not being injected properly if the component is outside of the current DOM tree. See: react-dnd/react-dnd#227
meh! Links to http://notlouieagain.com/ are not responding ... |
I found the root cause of my issue. I had to stop using the DragDropContextProvider to wrap my DropTargets and DragSources. See the example below. export default class YourApp {
render() {
return (
<DragDropContextProvider backend={HTML5Backend}>
/* ... */
</DragDropContextProvider>
)
}
} Instead, I had to use the DragDropContext to wrap my entire class like below. class YourApp {
/* ... */
}
export default DragDropContext(HTML5Backend)(YourApp) This immediately fixed the problem for me. |
When using two or more interoperable sortable lists, monitor.isDragging() returns false sometimes when it should return true when dragging an item from one container to the other.
Setup: starting from the simple sortable demo, add another container and set of sortable objects. Cards should be draggable from one container to the other, sortable within their own container, and sortable as they are dragged from one container to the other.
The issue occurs when moving a card from one container to the other. The card component depends upon the isDragging property (injected by the DragSource decorator) to determine opacity, however, when the item is dragged from one container to the other, the global monitor changes the sourceId which no longer matches the dragged component and ends up returning false for calls to isDragging when it should return true.
Since the dragsource already requires a consistent globally unique key per draggable object (other stuff really misbehaves if your draggable component's keys change at any time), can the code use that key when designating the sourceId so that dragging from one container works correctly?
Let me know if you need to see the example code. My code demonstrating this issue is based off the simple sortable demo.
The text was updated successfully, but these errors were encountered: