Skip to content

Prevent dropping at first root level item #146

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

Closed
jasonvarga opened this issue Feb 3, 2025 · 2 comments
Closed

Prevent dropping at first root level item #146

jasonvarga opened this issue Feb 3, 2025 · 2 comments

Comments

@jasonvarga
Copy link

Hello.

I am trying to prevent nodes being dragged to the top of the tree.

I tried the following, but it doesn't work since targetInfo is undefined.

rootDroppable(stat) {
    return dragContext.targetInfo.indexBeforeDrop === 0;
}
@phphe
Copy link
Owner

phphe commented Feb 3, 2025

targetInfo is not undefined untill mouseup, check #128, try dragContext.closestNode

@jasonvarga
Copy link
Author

I saw that issue and noticed dragContext.closestNode was also undefined. But I was still on 2.8.2. Upgrading to 2.9.4 fixed that.

I was able to prevent dragging to the top node by doing if (dragContext.closestNode === null) return false;.

Thanks!

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

2 participants