React-beautiful-dnd: Add support for id's of type number

Created on 16 Jan 2018  ·  7Comments  ·  Source: atlassian/react-beautiful-dnd

Bug or feature request?

Bug?

Expected behavior

I am working on a variant of the Basic usage example

I would expect it possible to drag and drop the first element.

Actual behavior

It is not possible to drag and drop the first element. I get the following errs:

  • Cannot start capturing dimensions with an invalid request 0
  • could not find draggable in store after lift
  • not able to drop in phase: 'IDLE'

I believe the reason is that id: 0 is messing up (classic problem, eh?). I have the following item list:

const items = [
  { id: 0, content: 'nul' },
  { id: 1, content: 'en' },
  { id: 2, content: 'to' },
  { id: 3, content: 'tre' },
  { id: 4, content: 'fire' },
];

If I remove the first item from the list, then all is good ...

Steps to reproduce

Browser version

Demo

good first issue ❤️ new feature 🎨

Most helpful comment

both

All 7 comments

Ids need to be a string. People keep hitting against this though. Perhaps
it is worth extending ids so they can also be numbers
On Wed, 17 Jan 2018 at 6:43 am, Martin Asser Hansen <
[email protected]> wrote:

Bug or feature request?

Bug?
Expected behavior

I am working on a variant of the Basic usage example
https://github.com/atlassian/react-beautiful-dnd#basic-usage-example

I would expect it possible to drag and drop the first element.
Actual behavior

It is not possible to drag and drop the first element. I get the following
errs:

  • Cannot start capturing dimensions with an invalid request 0
  • could not find draggable in store after lift
  • not able to drop in phase: 'IDLE'

I believe the reason is that id: 0 is messing up (classic problem, eh?).
I have the following item list:

const items = [
{ id: 0, content: 'nul' },
{ id: 1, content: 'en' },
{ id: 2, content: 'to' },
{ id: 3, content: 'tre' },
{ id: 4, content: 'fire' },
];

If I remove the first item from the list, then all is good ...
Steps to reproduce Browser version Demo


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/atlassian/react-beautiful-dnd/issues/274, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACFN7eFeuxXDm3UktLSlvwTduWNzK6hDks5tLPvJgaJpZM4RgUfr
.

Why not ;o)

both

This seems to be working already: https://codesandbox.io/s/k3vjp3qz0o

There are some situations where an id of 0 will fail truthy checks in some files

Is numeric support necessary? I'm used to db identifiers being numeric - but the react apollo/graphql transports them as strings. On the other end, render ids in HTML5 are string , and while passing ids other ways, like jsonwebtoken, they are passed as string, as well.

For now, I think we can just keep it as a string. This is easy for consumers to cast

Was this page helpful?
0 / 5 - 0 ratings