Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
340 views
in Technique[技术] by (71.8m points)

javascript - Draggable div given 100% of parent when dragged with React-Beautiful-DND

I'm using react-beautiful-dnd to create a simple allocations screen for some adjudicators to a competition room. Unfortunately, my setup has left me with two problems that I've been unable to resolve.

  1. When dragging a 'Draggable' div it's given a width = 100% of its parent (Droppable) which causes horrible transforms to be given to the elements in the destination Droppables.

  2. Now, when I add a second Draggable to a given Droppable instead of it being a horizontal allocation as the transforms and such suggest the elements end up stacked together and underneath other Droppable elements.

I've tried looking for other transforms in parents, and the only way that I've found to patch issue 1 is to set a fixed width on the Droppable but something feels as though this is poor practice (no examples I've found show this being necessary).

As additional context to #1 - I've looked at the style being given by DraggableProps which shows that the transforms and the width themselves are both set as a fixed width = the width of the Droppable parent.

I'd appreciate even just some direction for debugging since I realise that searching an entire codebase like this is far above and beyond the norm to be expected.

Image of Issue #1 - the horrifying width given for transforms Image of Issue #2 - the stacked elements

Full source, because I suspect it is relating to some bad choice of parent up the food chain: https://github.com/SteRoy/Tabbi3/tree/master/frontend/src/Tournament/AllocationPage


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The resolution was that flex display was missing from the Droppable and giving Draggable a fixed width essentially resolved the width problem - a bit of padding to tidy up (and you can see the full resolution in a dedicated commit above).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...