From 1912e716a221b0b819dbf412d0df1a57389e3032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Ventura?= Date: Wed, 8 Feb 2017 14:26:27 +0100 Subject: [PATCH] Rselect block after moving. --- blocks.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/blocks.js b/blocks.js index bb7557938bf1c3..de1842d202ef03 100644 --- a/blocks.js +++ b/blocks.js @@ -109,17 +109,23 @@ function attachControlActions() { event.stopPropagation(); swapNodes( selectedBlock, getPreviousSibling( selectedBlock ) ); attachBlockHandlers(); + reselect(); }, false ); } else if ( 'down' === classes ) { node.addEventListener( 'click', function() { event.stopPropagation(); swapNodes( selectedBlock, getNextSibling( selectedBlock ) ); attachBlockHandlers(); + reselect(); }, false ); } } ); } +function reselect() { + document.getElementsByClassName( 'is-selected' )[0].click(); +} + function swapNodes( a, b ) { if ( ! ( a && b ) ) { return false; @@ -130,9 +136,6 @@ function swapNodes( a, b ) { return false; } - // how do we handle controls? - showControls( b ); - // insert node copies before removal parent.replaceChild( b.cloneNode( true ), a ); parent.replaceChild( a.cloneNode( true ), b );