1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-17 12:41:44 +02:00

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.
This commit is contained in:
Julien Poissonnier
2018-02-12 23:36:51 +01:00
committed by Ian Storm Taylor
parent a17ea2cc21
commit e3abba0a29

View File

@@ -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