From e3abba0a291e5aa839fcefe9dad171faaf43ad72 Mon Sep 17 00:00:00 2001 From: Julien Poissonnier Date: Mon, 12 Feb 2018 23:36:51 +0100 Subject: [PATCH] Fix drag and dropping a node "forward" in the document (#1621) When drag and dropping a node to a position earlier in the document, the node is inserted and then removed right after. Regenerate the key to make sure the old node is removed instead of the new one. --- packages/slate-react/src/plugins/after.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/slate-react/src/plugins/after.js b/packages/slate-react/src/plugins/after.js index a9815ca43..2bcefcdad 100644 --- a/packages/slate-react/src/plugins/after.js +++ b/packages/slate-react/src/plugins/after.js @@ -264,11 +264,11 @@ function AfterPlugin() { } if (type == 'node' && Block.isBlock(node)) { - change.insertBlock(node).removeNodeByKey(node.key) + change.insertBlock(node.regenerateKey()).removeNodeByKey(node.key) } if (type == 'node' && Inline.isInline(node)) { - change.insertInline(node).removeNodeByKey(node.key) + change.insertInline(node.regenerateKey()).removeNodeByKey(node.key) } // COMPAT: React's onSelect event breaks after an onDrop event