Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onMove receives inconsistent parentId and index #247

Open
davidnaas opened this issue Apr 23, 2024 · 7 comments
Open

onMove receives inconsistent parentId and index #247

davidnaas opened this issue Apr 23, 2024 · 7 comments

Comments

@davidnaas
Copy link

davidnaas commented Apr 23, 2024

Inconsistent index
Cursor would imply new index should be 1 but is reported as 2
Kapture 2024-04-23 at 12 23 49

Inconsistent parentId
Cursor and node.willReceiveDrop indicates that a drop will NOT happen, yet parentId is that of the Box rather than Container

This behaviour only happens after first moving Slider into a Box, then out again. Somehow that Slider continues to receive the Box as the parent when being moved. It should also be noted that those boxes are internal nodes in all cases, i.e. children is always an array
Kapture 2024-04-23 at 12 21 57

@RAFA3L
Copy link

RAFA3L commented Aug 14, 2024

Same here, moving a node from a nested node to another one get an incorrect index, then if you move the node inside the same level the index is correct.

@surajair
Copy link

Yes. Same here. onMove is giving incorrect position. at root level, if there are two nodes, it am getting position as 2 whereas it should have been 1.

@RAFA3L
Copy link

RAFA3L commented Aug 14, 2024

Possible solution? instead of get the index from the args in onMove, yo can get the proper one from the tree state like this, where tree is the ref to the component.

tree.state.dnd.index;

@RAFA3L
Copy link

RAFA3L commented Aug 15, 2024

I discovered that the problem in my case is when the node next position is above the old one, even to another level but always dragging it upward, then the index jump one step more.

2024-08-14_23-17-07

@surajair
Copy link

Possible solution? instead of get the index from the args in onMove, yo can get the proper one from the tree state like this, where tree is the ref to the component.

tree.state.dnd.index;

Will try this

@RAFA3L
Copy link

RAFA3L commented Aug 26, 2024

@surajair the index in the state has the same problem, dragging the node upward the index is increased by 1, you can calculate the direction getting the old rowIndex of the node from the tree instance

@furkanalptokac
Copy link

Same here. When I drag a node above or below itself, index value changes. According to the example, index is 0 on above but index is 1 on below. It moves under next element when index is 1 with a simple dnd logic. That case is completely blocking me.
Screen Recording 2024-12-24 181332

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants