Skip to content
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

Deleting workspace comments sometimes throws console warnings #1848

Closed
rachel-fenichel opened this issue May 11, 2018 · 0 comments
Closed

Deleting workspace comments sometimes throws console warnings #1848

rachel-fenichel opened this issue May 11, 2018 · 0 comments
Labels
component: comments help wanted External contributions actively solicited issue: bug Describes why the code or behaviour is wrong low priority

Comments

@rachel-fenichel
Copy link
Collaborator

Problem statement

Deleting a workspace comment by clicking on the "x" icon when it's selected deletes the comment, but throws warnings.

Expected Behavior

Comment is deleted and there are no warnings.

Steps to Reproduce

  1. Create a ws comment
  2. Select the comment for editing
  3. Click the comment's delete icon.

Stack Traces

Uncaught TypeError: Cannot read property 'blur' of null
    at workspace_comment_render_svg.js:456
(anonymous) @ workspace_comment_render_svg.js:456
setTimeout (async)
Blockly.WorkspaceCommentSvg.blurFocus @ workspace_comment_render_svg.js:455
Blockly.WorkspaceCommentSvg.removeSelect @ workspace_comment_svg.js:242
Blockly.WorkspaceCommentSvg.unselect @ workspace_comment_svg.js:221
Blockly.WorkspaceCommentSvg.dispose @ workspace_comment_svg.js:109
Blockly.WorkspaceCommentSvg.deleteMouseUp_ @ workspace_comment_render_svg.js:308
wrapFunc @ blockly.js:458

workspace_comment_render_svg.js:456 Uncaught TypeError: Cannot read property 'blur' of null
    at workspace_comment_render_svg.js:456
(anonymous) @ workspace_comment_render_svg.js:456
setTimeout (async)
Blockly.WorkspaceCommentSvg.blurFocus @ workspace_comment_render_svg.js:455
Blockly.WorkspaceCommentSvg.unselect @ workspace_comment_svg.js:222
Blockly.WorkspaceCommentSvg.dispose @ workspace_comment_svg.js:109
Blockly.WorkspaceCommentSvg.deleteMouseUp_ @ workspace_comment_render_svg.js:308
wrapFunc @ blockly.js:458

Additional Information

This is because we're deferring some style changes to the end of the frame, and the relevant svg elements have already been deleted by then. The solution is probably to explicitly track whether the comment has already been deleted.

Relevant code in workspace_comment_render_svg:

/**
 * Remove focus from the text area.
 * @package
 */
Blockly.WorkspaceCommentSvg.prototype.blurFocus = function() {
  var comment = this;
  this.focused_ = false;
  // Defer CSS changes.
  setTimeout(function() {
    comment.textarea_.blur();
    comment.removeFocus();
    Blockly.utils.removeClass(
        comment.svgRectTarget_, 'blocklyCommentTargetFocused');
    Blockly.utils.removeClass(
        comment.svgHandleTarget_, 'blocklyCommentHandleTargetFocused');
  }, 0);
};

@rachel-fenichel rachel-fenichel added issue: bug Describes why the code or behaviour is wrong help wanted External contributions actively solicited component: comments labels May 11, 2018
mehdi-yeganeh added a commit to mehdi-yeganeh/blockly that referenced this issue Dec 4, 2018
mehdi-yeganeh added a commit to mehdi-yeganeh/blockly that referenced this issue Dec 5, 2018
rachel-fenichel added a commit that referenced this issue Dec 5, 2018
#1848 Fixed throw console warning when deleting workspace comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: comments help wanted External contributions actively solicited issue: bug Describes why the code or behaviour is wrong low priority
Projects
No open projects
Development

No branches or pull requests

2 participants