diff --git a/accessible/clipboard.service.js b/accessible/clipboard.service.js index 43c93b278..41e5bdb14 100644 --- a/accessible/clipboard.service.js +++ b/accessible/clipboard.service.js @@ -46,13 +46,20 @@ blocklyApp.ClipboardService = ng.core this.areConnectionsCompatible_(connection, nextConnection)); }, isMovableToMarkedConnection: function(block) { - // It should not be possible to move a block to one of its own - // connections. - if (this.markedConnection_ && - this.markedConnection_.sourceBlock_.id == block.id) { + // It should not be possible to move any ancestor of the block containing + // the marked spot to the marked spot. + if (!this.markedConnection_) { return false; } + var markedSpotAncestorBlock = this.markedConnection_.getSourceBlock(); + while (markedSpotAncestorBlock) { + if (markedSpotAncestorBlock.id == block.id) { + return false; + } + markedSpotAncestorBlock = markedSpotAncestorBlock.getParent(); + } + return this.canBeCopiedToMarkedConnection(block); }, canBeCopiedToMarkedConnection: function(block) {