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 not working in controlled component.

See original GitHub issue

I am working on a similar functionality like Demo 15 - Drag From Outside. I notice that provided example is an uncontrolled component.

When I try to implement a similar feature with a controlled component (layout state is controlled when onLayoutChange callback trigger). I am getting undefined in the onDrop callback.

Sandbox is created to demonstrate this issue. How I can get a drop element position in the grid?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
jdbencecommented, Mar 14, 2021

Something like this probably would work for your sandbox

const onLayoutChange = (layout) => {
    if(!layout.find(li => li.i === 'Dropped')){
      setLayoutState(layout);
    }
};
1reaction
gonzofishcommented, Mar 25, 2021

the i for me is '__dropping-elem__'

Read more comments on GitHub >

github_iconTop Results From Across the Web

draggable component in react not working as expected
I am trying to make a draggable button using react. The button drags over the page in a proper manner but when I...
Read more >
Drag and Drop in React Components - Pluralsight
This guide will show component composition to add drag capabilities to a React component and turn a React component into a drop target....
Read more >
Support dragging a copy (leave original in place) #216 - GitHub
In your source Droppable, set isDropDisabled={true}. This stops the source re-ordering when you drag an item - but it will leave a blank...
Read more >
How to implement drag and drop in React with React DnD
The Drag and Drop API is an integral part of most modern applications, ... For example, a Trello layout would work out of...
Read more >
React Draggable Components: A Complete Guide - Copycat
Items in React-Draggable are draggable regardless of their current positioning (relative, absolute, or static). If the item you are dragging ...
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