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

Unable to find drag handle when id is integer #1512

Closed
SiebeVE opened this issue Sep 23, 2019 · 9 comments
Closed

Unable to find drag handle when id is integer #1512

SiebeVE opened this issue Sep 23, 2019 · 9 comments

Comments

@SiebeVE
Copy link

SiebeVE commented Sep 23, 2019

Expected behavior

When using a draggableId that is an int, the library is unable to find the drag handle.
This is due to the strict check on: https://github.com/atlassian/react-beautiful-dnd/blob/dev/src/view/get-elements/find-draggable.js#L17.
We get this id by fetching it from the dom, but comparing it to the id received from react (that can be an int or a string)

Actual behavior

Renders with errors and doesn't enable drag 'n drop.
Given error:

A fatal error has occurred. Any existing drag will be cancelled.> Invariant failed:
Draggable[id: 309]: Unable to find drag handle

Steps to reproduce

Create a component and make sure you give the draggable id an integer value

Suggested solution?

Don't use a strict check or cast to integer when possible?

What version of React are you using?

16.9.0

What version of react-beautiful-dnd are you running?

12.0.0-beta-1

What browser are you using?

Latest chrome

Demo

https://codesandbox.io/embed/vertical-list-vs189

@alexreardon
Copy link
Collaborator

This is a tricky one as we do state that draggableId needs to be a string. It is a bit of a rabbit hole to start treating it as maybe an int

@alexreardon
Copy link
Collaborator

Perhaps we should throw if draggableId is not a string

@alexreardon
Copy link
Collaborator

12.0 would be a good opportunity to add this check

@SiebeVE
Copy link
Author

SiebeVE commented Sep 24, 2019

That sounds like a good idea!

I will try to write a PR for this check

@alexreardon
Copy link
Collaborator

#950 #921

@alexreardon
Copy link
Collaborator

Don't worry about creating a PR @SiebeVE. I'll make the change as I want to test out a few things with it

@alexreardon
Copy link
Collaborator

This has been changed in 12.0.0-beta.3. An error will now be thrown if draggableId or droppableId is not a string

@alexreardon
Copy link
Collaborator

#1317

@Alan-Fisher
Copy link

draggableId needs to be a string

Probably should be in the docs...

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

No branches or pull requests

3 participants