Hi Rupak,
Not on the Blockly team so I don't know if this was intended, but it seems strange to me that it would count the child blocks for the delete message but not remove them. In fact, if you attach another text block to the create text block, all blocks are deleted so I'm fairly certain this is a bug.
The relevant code can be found in the callback here:
https://github.com/google/blockly/blob/master/core/contextmenu_items.js#L458. When it calls
scope.block.dispose(true, true), it's passing true for healStack (
https://github.com/google/blockly/blob/master/core/block.js#L357); the other true seems accidental as the method only takes one argument. In the current implementation, if healStack is true, it attempts to connect the stack of blocks below it to the deleted block's parent (if it's a statement block, which is not relevant here). However, if the deleted block has an output connection as is the case with the create text block, and that block only has one block connected to its value input, the text block in this case
(
https://github.com/google/blockly/blob/master/core/block.js#L495), it will attempt to connect the deleted block's child to the deleted block's parent (the variable set block). This is why if you have one text block connected, it succeeds in reconnecting it to the variable set block, but if you have multiple ones, getOnlyValueConnection_ returns with null so it deletes the child text blocks as intended (obviously can't connect two text blocks to a single variable set block).
A simple monkey-patch solution that you could use for now would be to redefine Blockly.Block.prototype.unplug so that this.unplugFromRow_ is called with false instead of opt_healStack. This way it will never try to reconnect value input blocks of deleted blocks even if there's only one. Not a recommended solution in general, but this could be a quick fix for now until this likely bug is corrected.
Blockly.Block.prototype.unplug = function(opt_healStack) {
if (this.outputConnection) {
this.unplugFromRow_(false);
} else if (this.previousConnection) {
this.unplugFromStack_(opt_healStack);
}
};
Best,
Jason