react-arborist
react-arborist copied to clipboard
Open Folder After Hovering Over It
If you are dragging a node over a closed folder for a certain period of time, open that node.
I'm using @percy507's solution from his PR to achieve the above. ☝️ https://github.com/percy507/react-arborist/blob/d48f6b4e00b5e12cd9e519f90326659b0de9645e/packages/showcase/pages/cities.tsx
// Auto open folder node while the dragging node on it
if (node.state.willReceiveDrop && node.isClosed) {
// Why using setTimeout? Because if not, the console will report a warnning of bad setState().
setTimeout(() => {
// Second check if need open the node, because the dragging node may just pass the folder node
if (node.state.willReceiveDrop) node.open();
}, 666);
}