Skip to content

DnD into shadow DOM will not set event.composed and event.composedPath() #97

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

Open
mmuehlich opened this issue Apr 18, 2025 · 0 comments · May be fixed by #98
Open

DnD into shadow DOM will not set event.composed and event.composedPath() #97

mmuehlich opened this issue Apr 18, 2025 · 0 comments · May be fixed by #98

Comments

@mmuehlich
Copy link

The current approach with dropRoot: Document | ShadowRoot works well, if the DragEvent is caught within the shadow DOM but fails in cases, where either

  • the dropRoot is outside the shadow DOM (e.g. because the shadow DOM is not loaded yet) - or
  • the DragEvent should be caught inside AND outside of the shadow DOM

in those cases, native DnD could be implemented using Event: composedPath :

e.g.

target.ondragover = (ev: DragEvent) => {
    const path = ev.composedPath();
    const target = path.find((t) => t.classList.contains("my-valid-drop-target"));
    if (target && ev.dataTransfer) {
        ev.dataTransfer.dropEffect = "move";
        ...
    }
};

This approach fails with drag-drop-touch-js because Event: composed and Event: composedPath are not set.

I will create a pull request to set composed and composedPath and link it to this issue.

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

Successfully merging a pull request may close this issue.

1 participant