Skip to content

Drag & drop doesn't work properly when an item is hidden #112

Closed
@avanrish

Description

@avanrish

Describe the bug
When you don't render an item (or hide it) included in parent's children array (e.g. "Meals" in "root"), it still is recognized during drag and drop (issue doesn't exist e.g. on click), which makes all following elements invalid.
You can check the bug on codesandbox

To Reproduce
Apply display: none; to the element or render null/fragment/empty element instead of it.

Expected behavior
On drop the hidden/not rendered item should be completely ignored. In my sandbox example: when I drag "Fruit" and drop on "Desserts", I should get "Desserts" in console or on preview, but I get "Meals". Basically everything after "Fruit" (or "Banana" if "Fruit" is expanded), becomes an item before including hidden/not rendered items.

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Microsoft Edge
  • Version: 103.0.1264.71

Additional context
In my project, I use 2 trees and they can contain any amount of items. I need to implement search functionality, but I can't use built-in due to the possible huge amount of items. Only visible items are added to the data object, but I still need to search for all items (I have API for that) and since I need drag & drop between them, I have to use 1 Controlled Environment so I thought the best idea would be to hide items that aren't in searched items' paths, but that won't work due to the issue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions