From 07d14c44ce3f48d750c998f8c083c8ce817e69b2 Mon Sep 17 00:00:00 2001 From: Johannes Wilm Date: Fri, 12 Oct 2018 10:20:27 +0200 Subject: [PATCH] allow dropping of copied content, part 1 Not sure how this is supposed to work, but without this change I can drag an item from one container to a second container with this second container having behaviour: 'copy'. If I don't add this, it is simply being removed from the first container. --- src/dropHandlers.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/dropHandlers.js b/src/dropHandlers.js index 8aabde3..2198905 100644 --- a/src/dropHandlers.js +++ b/src/dropHandlers.js @@ -18,7 +18,13 @@ export function domDropHandler({ element, draggables, layout, options }) { if (addedIndex !== null) { const wrapper = global.document.createElement('div'); wrapper.className = `${wrapperClass}`; - wrapper.appendChild(removedWrapper.firstElementChild || droppedElement); + wrapper.appendChild( + removedWrapper && removedWrapper.firstElementChild ? + removedWrapper.firstElementChild : + options.behaviour === 'move' ? + droppedElement : + droppedElement.cloneNode(true) + ); wrapper[containersInDraggable] = []; addChildAt(element, wrapper, addedIndex); if (addedIndex >= draggables.length) { @@ -46,4 +52,4 @@ export function reactDropHandler() { return { handler }; -} \ No newline at end of file +}