brimdata / react-arborist

The complete tree view component for React
MIT License
3.07k stars 140 forks source link

onMove index always = 0 #258

Open deniznet opened 4 months ago

deniznet commented 4 months ago

Hi! First of all, thanks for this library, it's cool! I try to make managment tree with data={data}, add onMove handler, but when ever it run - index alway has value 0. Why? And how to manage Move and Reorder by DragNDrop programmisticly?

onMove={(e) => {
   console.log('onMove ', e);
}}

in devTool:

onMove {dragIds: Array(1), parentId: '5184', index: 0, dragNodes: Array(1), parentNode: _NodeApi}dragIds: ['5183']dragNodes: [_NodeApi]index: 0parentId: "5184"parentNode: _NodeApi {tree: _TreeApi, id: '5184', data: {…}, level: 3, handleClick: ƒ, …}[[Prototype]]: Object

deniznet commented 4 months ago

Oo! It's incredible! I'v found solution! When openByDefault = true then onMove take index=0 always. But if I toggle to openByDefault=false, so onMove work perfectly! Why?

<Tree
        data={data}
        openByDefault={false}