Skip to content

Allow block comments to be editable on mobile by catching the mousedo… #1757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ Blockly.Comment.prototype.setVisible = function(visible) {
*/
Blockly.Comment.prototype.textareaFocus_ = function(_e) {
// Ideally this would be hooked to the focus event for the comment.
// However doing so in Firefox swallows the cursor for unknown reasons.
// So this is hooked to mouseup instead. No big deal.
// This is tied to mousedown, however doing so in Firefox swallows the cursor
// for unknown reasons.
// See https://github.com/LLK/scratch-blocks/issues/1631 for more history.
if (this.bubble_.promote_()) {
// Since the act of moving this node within the DOM causes a loss of focus,
// we need to reapply the focus.
Expand Down
2 changes: 1 addition & 1 deletion core/scratch_block_comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Blockly.ScratchBlockComment.prototype.createEditor_ = function() {
this.textarea_ = textarea;
this.textarea_.style.margin = (Blockly.ScratchBlockComment.TEXTAREA_OFFSET) + 'px';
this.foreignObject_.appendChild(body);
Blockly.bindEventWithChecks_(textarea, 'mouseup', this, this.textareaFocus_);
Blockly.bindEventWithChecks_(textarea, 'mousedown', this, this.textareaFocus_);
// Don't zoom with mousewheel.
Blockly.bindEventWithChecks_(textarea, 'wheel', this, function(e) {
e.stopPropagation();
Expand Down