atlassian / react-beautiful-dnd

Beautiful and accessible drag and drop for lists with React
https://react-beautiful-dnd.netlify.app
Other
33.29k stars 2.53k forks source link

Draggable does not render during drag inside react-modal #2221

Open steverecio opened 3 years ago

steverecio commented 3 years ago

Here is a code sample to demonstrate the issue: https://codesandbox.io/s/billowing-pond-xcn2t

When react-beautiful-dnd list is enclosed by a react-modal, the draggable item does not render during drags. In the codesandbox above, notice the List is the same component yet the draggable item renders during drag when placed in the app root but when it's placed in the react-modal, the item is invisible during drag.

trattles commented 3 years ago

EDIT: Short answer from the docs -> here

Parents with transforms on their position will cause issues. The above doc offers options.

See below cap of my inspector.

React Modal uses a portal and translates the div away from its original position. If you turn off that translation, everything works normally - and actually if you set overflow to 'visible' here you'll see that the item is indeed there, just nudged into the bottom right due to this translation.

To solve this problem - you might be able to render your draggable in a portal. Or you Might be able to solve this with some fancy CSS, or by using a different modal.

DevTools_-_codesandbox_io_s_billowing-pond-xcn2t_file__src_List_js
larissa-n commented 2 years ago

Keep in mind that you need to downgrade to version 12.0.0-beta.10 and below to use react-beautiful-dnd in a portal. See https://github.com/atlassian/react-beautiful-dnd/issues/2111