clauderic / dnd-kit

The modern, lightweight, performant, accessible and extensible drag & drop toolkit for React.
http://dndkit.com
MIT License
12.61k stars 628 forks source link

DND Kit doesnt work after collapsible/accordion open and close #990

Open kasvith opened 1 year ago

kasvith commented 1 year ago

Problem:

Everything works fine until we close a collapse. Then nothing works correctly (We are using antdesign, but i tried using headlessui also. Same result)

We arent using useSortable inside DragOverlay

What might be the issue?

<DndContext>
    // handle all events
    <SortableContext>
        // sort sections
        <Section>
            // we have useDroppable, useDraggable with two div elements.
            <div> // droppable
                <div> // draggable
                    <SortableContext>
                        <Collapse>
                            <Collapse.Header>
                                {{title}}
                            </Collapse.Header>
                            <Collapse.Body>
                                {{items}}
                            </Collapse.Body>
                        </Collapse>
                    </SortableContext>
                </div>
            </div>
        </Section>
        <Section></Section>
        <Section></Section>
    </SortableContext>

    <Portal>
        <DragOverlay></DragOverlay>
    </Portal>
</DndContext>

https://user-images.githubusercontent.com/13379595/211312743-83c8821b-51fe-45d3-9516-57214bcb905f.mp4

Reproducible: https://github.com/kasvith/dndkit-collapsible-reproduce Codesandbox: https://codesandbox.io/p/github/kasvith/dndkit-collapsible-reproduce

vldnovikov commented 1 year ago

@kasvith did you set the min-height for the last droppable? it looks like it has 0 height

kasvith commented 1 year ago

@vldnovikov no, droppable is even outside the collapse element. I checked the height is always there

kasvith commented 1 year ago

I updated example and provided a codesandbox

pavogq commented 1 year ago

@kasvith did you manage to find a fix for this? I'm having the same issue with headless ui and it's disclosure component.

kasvith commented 1 year ago

No luck

Voxz-ai commented 9 months ago

@kasvith did you happen to find a solution to this? i am running into the same issue.

kasvith commented 9 months ago

@Voxz-ai i changed the UX avoiding the collapsibles

Voxz-ai commented 9 months ago

For anyone else reading this, i was able to get it to work using MUI Accordion. If you are still working on it you should give that a try.

Cheers!