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

Drop does return initial drop event #33

Open
v1r0x opened this issue May 23, 2022 · 1 comment
Open

Drop does return initial drop event #33

v1r0x opened this issue May 23, 2022 · 1 comment

Comments

@v1r0x
Copy link
Contributor

v1r0x commented May 23, 2022

Version(if relevant): 6.0.1 (Vue 3)

Expected:

Dropping a node onto another should return an object of type DropData in @drop event handler.

Actual:

Instead the "normal" drop event is returned

drop { target: span, buttons: 0, clientX: 726, clientY: 527, layerX: 38, layerY: 9 }
@v1r0x
Copy link
Contributor Author

v1r0x commented May 24, 2022

I could track down the problem. The dragTarget is (in my case) an element inside my (custom) node component. This also contains a data-path attribute, but containing the ids of that path instead of the indices. What I did to fix that is to add this code snippet to ondrop method in packages/core/src/index.ts:

export function ondrop<T>(target: HTMLElement, dragTarget: HTMLElement | null | undefined, dragTargetRoot: TreeData<T>[], dropTargetRoot: TreeData<T>[], next: (dropData: DropData<T>) => void) {
  // this is the new check to get the correct HTMLElement
  while (dragTarget && !dragTarget.classList.contains('tree-anchor')) {
    dragTarget = dragTarget.parentElement
  }

I don't know if this only affects the drop event or also others. I also don't know if this is something that has changed with Vue3 or is related to my custom component. So I'm not sure if this is worth a PR or not.
(I also have another problem with wrong DropPosition which I have to fix first :D)

Edit:
This also affects dragTarget in ondrag method in packages/core/src/index.ts

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

No branches or pull requests

2 participants