react-arborist icon indicating copy to clipboard operation
react-arborist copied to clipboard

Open Folder After Hovering Over It

Open jameskerr opened this issue 1 year ago • 1 comments

If you are dragging a node over a closed folder for a certain period of time, open that node.

jameskerr avatar Feb 01 '23 21:02 jameskerr

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);
  }

Marius-AdamDT avatar Feb 02 '23 11:02 Marius-AdamDT