Force focus after block comments are created

This commit is contained in:
Paul Kaplan 2019-07-29 14:41:57 -04:00
parent c72e6934b4
commit e0830881f6
2 changed files with 8 additions and 3 deletions

View file

@ -293,6 +293,7 @@ Blockly.ContextMenu.blockCommentOption = function(block) {
commentOption.text = Blockly.Msg.ADD_COMMENT;
commentOption.callback = function() {
block.setCommentText('');
block.comment.focus();
};
}
return commentOption;

View file

@ -244,9 +244,6 @@ Blockly.ScratchBlockComment.prototype.createEditor_ = function() {
this.text_ = textarea.value;
}
});
setTimeout(function() {
textarea.focus();
}, 0);
// Label for comment top bar when comment is minimized
this.label_ = this.getLabelText();
@ -637,3 +634,10 @@ Blockly.ScratchBlockComment.prototype.dispose = function() {
this.workspace.removeTopComment(this);
Blockly.Icon.prototype.dispose.call(this);
};
/**
* Focus this comments textarea.
*/
Blockly.ScratchBlockComment.prototype.focus = function() {
this.textarea_.focus();
};