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

Fix/draggable only when can drag #3187

Merged

Conversation

seamuslowry
Copy link
Contributor

fixes #2909

I saw the same issue as mentioned in the PR and propose the fix in this PR.
When the attribute is set to "true" while canDrag is false, some (or perhaps all, but I cannot vouch for that) browsers will still allow the user to drag the node. react-dnd does not appear to consider it as being dragged and will not employ the same drop behavior, but it would be preferable to have the attribute match canDrag.

@darthtrevino darthtrevino merged commit 29405b1 into react-dnd:main Feb 3, 2022
darthtrevino added a commit that referenced this pull request Feb 3, 2022
* check monitor for draggable

* versioning strategy with patch on changed repo and declined on all others

* fix: use string type for setting html attribute

* fix: always set the draggable attribute on connectDragSource

* fix: update semver doc

Co-authored-by: Chris Trevino <chtrevin@microsoft.com>
@dmbarry86
Copy link

dmbarry86 commented Feb 6, 2022

I've just updated from 14.0.3 to 15.1.0 and suddenly my components are no longer draggable after initial drop. I've just done some quick debugging and it seems that the fix is to set canDrag to be true in the useDrag hook. Previously I had omitted canDrag because the doc suggests it's optional.

image

Is the doc out of date and I now need to set canDrag or is there something else I am missing? I'm not sure if my issues relates to this particular change so apologies if not and it deserves it's own issue.

@dmbarry86
Copy link

dmbarry86 commented Feb 6, 2022

I've just done some quick debugging and it seems that the fix is to set canDrag to be true in the useDrag hook.

This is misleading. I was running in dev mode with hot reload when I made this change and suddenly my components were draggable again after initial drop. Fresh app start with the same change and they are no longer draggable after initial drop. I think there's something else going on here. I'll have to debug further tomorrow.

@dmbarry86
Copy link

It appears that any change inside the useDrag hook makes components draggable again when in dev mode with hot reload, e.g. a random console.log inside item makes them draggable again. Fresh restart and components are no longer draggable again.

@dmbarry86
Copy link

Issue appears to be with react-dnd-html5-backend library. 14.1.0 is the last working version. All other versions I can no longer drag more than once.

@darthtrevino
Copy link
Member

@dmbarry86 - that is really strange- the examples I have on hand all appear to work properly. Can you draft up an example?

@dmbarry86
Copy link

@dmbarry86 - that is really strange- the examples I have on hand all appear to work properly. Can you draft up an example?

See #3378

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

Successfully merging this pull request may close these issues.

The HTML5Backend should determine draggable from canDrag
3 participants