question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Drag from outside to inside an Iframe

See original GitHub issue

There seems to be a lot of talk about Iframe support and you can setup DragDropContextProvider from within an Iframe, however, it doesn’t seem possible to drag from outside to inside of an iframe.

<DragDropContextProvider backend={HTML5Backend}>
  <div>
    <Frame style={{ heigth: '400px', width: '100%' }}>
      <div style={{ clear: 'both' }}>
        <Dustbin />
      </div>
    </Frame>
    <div style={{ overflow: 'hidden', clear: 'both' }}>
      <Box name="Glass" />
      <Box name="Banana" />
      <Box name="Paper" />
    </div>
  </div>
</DragDropContextProvider>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
paztiscommented, Dec 10, 2020

I’ve just found one way oy do it but I access private properties of HTML5Backend for this:

import {useDragDropManager} from 'react-dnd';
import Frame, {FrameContextConsumer} from 'react-frame-component';

...

const dragDropManager = useDragDropManager();

return (
  <Frame>
    <FrameContextConsumer>
      {
        // Callback is invoked with iframe's window and document instances
        ({document, window}) => {
          const backend = dragDropManager.getBackend();
          (backend as any).addEventListeners(window); // => add listeners on the chind iframe
        }
      }
     </FrameContextConsumer>
     <all the frame display I need />
  </Frame>
);

But to be able to do this, I need to be able to access addEventListeners / removeEventListeners method of the backend, that are not public at all.

Is is possible to make them public ?

3reactions
nbwarcommented, Sep 21, 2017

Made a quick Backend to support cross iframe support. May not be the best solution but gets the job done for now. Main change is how HTML5Backend references this.window. Changed it to this.windows that stores all iframe windows within the parent window.

https://github.com/nbwar/react-dnd-multi-iframe-backend

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to move / drag element from outside to iframe
One possible solution would be to try extending the Selenium ActionChains API and implement new method(s) that would allow you to start the...
Read more >
Position and Drag iframe | CRIMX BLOG
Drag start is triggered by a draggable element inside iframe. For better performance, dragging and drag end event listeners are attached in drag...
Read more >
How to drag and drop inside iframe . - Google Groups
Hi all, I am trying to drag an element from outside a frame and drop to inside but drag and drop is not...
Read more >
Drag Between Two Iframes - CodePen
See http://stackoverflow.com/questions/28879784/javascript-jquery-drag-and-drop-element-between-two-iframes...
Read more >
936299 - Drag drop inside iframe not working - Monorail
jsfiddle opens your code in an iframe so your own iframe is nested inside another iframe which triggers the bug [tentatively] introduced by ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found