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

Support: Web components with shadow dom #15

Open
rstoneIDBS opened this issue Apr 2, 2024 · 8 comments
Open

Support: Web components with shadow dom #15

rstoneIDBS opened this issue Apr 2, 2024 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@rstoneIDBS
Copy link

Looking at the code in "element-adapter.js":

 var target = event.target;

 // see if the thing being dragged is owned by us
 var entry = draggableRegistry.get(target);

If the dragged element is contained within the shadow root of another web component then 'target' above won't be the element being dragged but will instead be the web component due to event re-targetting. The following code sandbox shows the issue:

https://codesandbox.io/p/sandbox/pdnd-web-components-forked-l8f6tv

@alexreardon
Copy link
Collaborator

Thanks @rstoneIDBS.

Here is a potential plan of attack:

  • Could you please convert over one of our examples to use web components (ideally the board one as it exercises a decent amount of API surface area)
  • I'll take the example and make the changes required to get everything working with web components
  • I'll add browser integration tests on the new web component board example to help ensure we don't regress our support

@alexreardon alexreardon changed the title Drag & drop with web-components/shadow dom appears to be broken Support: Web components with shadow dom Apr 2, 2024
@rstoneIDBS
Copy link
Author

Thanks @rstoneIDBS.

Here is a potential plan of attack:

  • Could you please convert over one of our examples to use web components (ideally the board one as it exercises a decent amount of API surface area)
  • I'll take the example and make the changes required to get everything working with web components
  • I'll add browser integration tests on the new web component board example to help ensure we don't regress our support

Hi @alexreardon , this is something I might be able to look into but it is going to take some time as I'm pretty busy with other things. We were investigating adding some drag & drop features to a PoC but have now moved on from that so its not a priority for us at the moment.

@alexreardon
Copy link
Collaborator

If somebody is willing to put together our board example with web components that leverages shadow dom, I can take a look at adding support to pdnd :)

@alexreardon alexreardon added help wanted Extra attention is needed and removed waiting on response labels Apr 7, 2024
@alexreardon
Copy link
Collaborator

@keithamus 👋

@alexreardon
Copy link
Collaborator

Thanks for your original PR @rstoneIDBS. I suspect there is not a whole lot we will need to do to get things working. I am not confident enough with web components right now to successfully make the changes required. It would be great to get the assistance from the web components community for this one.

@alexreardon
Copy link
Collaborator

Relevant data points:

  • drag handles currently use document.elementFromPoint as a part of the check (we could look a removing drag handles though as drag handles can be achieved by using a custom native drag preview)
  • for our drop target lookup, we search up the tree for drop targets using element.closest(dropTargetSelector)
  • auto scroller uses elementFromPoint to determine what the user is currently over
    -auto scroller uses target.closest(scrollContainerSelector) to find all the relevant scroll containers

@rstoneIDBS
Copy link
Author

@alexreardon - I would like to be able to help out here, but at the moment I just don't have the bandwidth :(

@driskull
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants