dnd
dnd copied to clipboard
add support to granular control over which items can be combined with within the list
Description
I would like to discuss concerns the atlassian team may had to decided to not support granular combine control in the original library and whether we can bring it up here?
According to their description here
We could move to the isCombineEnabled prop from a <Droppable /> to a <Draggable /> to allow this sort of customisation. However, in order to ship this huge feature we went a bit simplier to start with
In our project we are using this library in combination with the Tree and have a LEAF type of node that can't be combine targets but for the other nodes combine should work. So I ended up boldly forcing some additional prop to support granular control.
Here is the pull request with the change I use https://github.com/hello-pangea/dnd/pull/655 we can consider any other API for that feature and I will probably find time to work on this further if needed.
I will be glad to hear any ideas on the matter and if I missed some use-cases (I probably have not covered virtualization as I don't use it)
P.S. I'am glad to see a community fork of this library because I thought that as atlassian have no time to support this library then we are stuck! Found this fork only after switching to React 18 and searching issues in original repository.
Thanks for moving it to Typescript and supporting the React 18!
Here is the example usage of the API suggested in the pull request
const isCombineAllowedForItem = (combineWith: DraggableDescriptor) => {
const treeItem = tree.items[combineWith.id];
return treeItem && treeItem.data && treeItem.data.item.isCluster;
}
return (
<Tree
tree={tree}
isNestingEnabled={true}
isDragEnabled={true}
offsetPerLevel={22}
renderItem={renderItem}
onExpand={onExpand}
onCollapse={onCollapse}
onDragEnd={onDragEnd}
onDestinationChange={onDestinationChange}
isCombineAllowedForItem={isCombineAllowedForItem}
/>
)
since we have the whole tree that have all items already indexed in the .items field we can easily get and check conditions on per Item level