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

HTML Backend leaks event listeners to all elements on page, not just those within Context #3596

Open
denno020 opened this issue Oct 15, 2023 · 0 comments

Comments

@denno020
Copy link

Describe the bug

When using the HTML5 backend within the DndProvider anywhere on the page, event listeners for drag and drop events are attached to every HTML element within the page, not just the elements that are children of the DndProvider context.

Reproduction

Live Reproduction

Steps to reproduce the behavior:

  1. Open reproduction
  2. Open a website with links (example: https://www.jaycar.com.au/)
  3. Display reproduction and website loaded in step 2 on the same monitor, side by side
  4. Click on one of the links from the website in step 2, and drag it into the input in the reproduction

Expected behavior

The URL that is dragged into the input would be pasted.

** Actual beavior**

Nothing happens, as an event listener that React DnD has attached to the input, prevents the event from propagating, and therefore prevents the URL from being pasted into the input

Screenshots

The follow screen recording has the React DnD Provider being rendered

Dragging.link.into.input.doesn.t.work.mp4

The following screen recording removes the React DnD Provider, to show the expected behaviour

Dragging.link.into.input.does.work.mp4

Additional context

I have tried passing options into the context, setting a rootElement element, however if the DnD context is being rendered at the same time that the whole application is being rendered, then on the first pass (the first time that DnD is run), the ref will be null, so DnD falls back to using window. On subsequent re-renders, the initial result has been cached, therefore it is re-used, so the rootElement stays as window

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

1 participant