question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DndContext reducers all point to the same initial state variable, which is causing id collisions across nested and sibling providers

See original GitHub issue

Hi, First of all, great job building this. It’s an awesome library.

I am facing a problem with a use case where I have a nested structure. Can you please help resolve this?

I have a structure similar to the following:

<DndContext>
   <div>
        <Draggable />
        <Draggable />
        {/* multiple draggable items */}
    </div>

    <div>
          <Droppable>
             <DndContext>
                  <SortableContext>
                        <SortableItem />
                        <SortableItem />
                        {/* multiple sortable items */}
                  </SortableContext>
             </DndContext>
         </Droppable>

        <Droppable>
             <DndContext>
                  <SortableContext>
                        <SortableItem />
                        <SortableItem />
                        {/* multiple sortable items */}
                  </SortableContext>
             </DndContext>
         </Droppable>
         {/* Multiple similar droppable items */}
    </div>
</DndContext>

Now, I am able to move the draggable items to droppable zones. But the events are not being detected when trying to sort items in the individual droppable zones. I assume it is something related to event bubbling, but not sure. Any help in this regard will be appreciated. Thanks 🙏

Codesandbox Link: https://codesandbox.io/s/dnd-kit-gm09q?file=/src/App.js

Demo: https://user-images.githubusercontent.com/17903466/104116991-a325a680-5343-11eb-96e0-469b168f83dd.mov

EDIT: In the same codesandbox, add an empty section and try to add Page 12 to it before anything else. It isn’t getting added. I don’t know if I am missing something here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
claudericcommented, Jan 12, 2021

The fix has shipped in @dnd-kit/core^1.0.1, let me know if you run into other issues related to unexpected id collisions

1reaction
claudericcommented, Jan 10, 2021

Hey @pbteja1998, I haven’t had time to look in-depth into the root cause of the issue in your case, that is, whether it is an issue in the library or a consumer error, but from what I can tell it appears like there was an id collision with your sortable items. I updated the id of the sortable items to something like sortable-${id} which seems to have resolved the collision. More investigation will be required though.

https://codesandbox.io/s/dnd-kit-forked-hhfkk?file=/src/App.js

As for the issue with pages that are scrolled in the sidebar, it’s an issue that was reported here and for which a fix is in progress: #43

Read more comments on GitHub >

github_iconTop Results From Across the Web

DndContext - @dnd-kit – Documentation
React context provides a way to pass data through the component tree without having to pass props down manually at every level. Therefore,...
Read more >
How to update the State on a DnD Component - Stack Overflow
You're main issue is in these lines: const oldIndex = items.indexOf(active.id); const newIndex = items.indexOf(over.id);.
Read more >
Calling PushPopupAsync crashes UWP app in release mode - Rg ...
Hi,. Rg.Plugins.Popup crashes in UWP in a app running in release mode (ARM build), tested on a Microsoft Lumia 650, Windows 10 mobile...
Read more >
The dnd-kit from clauderic - GithubHelp
DndContext reducers all point to the same initial state variable, which is causing id collisions across nested and sibling providers. Hi, First of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found