Skip to content

Commit

Permalink
fix: Don't try to set text fields to null on cancel (#5692)
Browse files Browse the repository at this point in the history
Mobile users get a window.prompt as an input, if they press the cancel button the return value is null.  Don't attempt to set the value of the field to null.

Caused errors in the custom note field which inherits from FieldTextInput.  Detected in Blockly Games Music.

This PR is for the master branch and includes a recompile.  The develop branch has changed enough that a cherrypick from develop to master won't work.  The bug in question represents a significant number of the errors being reported from Blockly Games.
  • Loading branch information
NeilFraser authored Nov 8, 2021
1 parent 0125d78 commit 500853a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion blockly_compressed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blockly_compressed.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion core/field_textinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(_opt_e,
Blockly.FieldTextInput.prototype.showPromptEditor_ = function() {
Blockly.prompt(Blockly.Msg['CHANGE_VALUE_TITLE'], this.getText(),
function(text) {
this.setValue(this.getValueFromEditorText_(text));
// Text is null if user pressed cancel button.
if (text !== null) {
this.setValue(this.getValueFromEditorText_(text));
}
}.bind(this));
};

Expand Down
13 changes: 0 additions & 13 deletions msg/json/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,6 @@
"CONTROLS_IF_IF_TOOLTIP": "tooltip - Describes [https://github.com/google/blockly/wiki/IfElse#block-modification if block modification].",
"CONTROLS_IF_ELSEIF_TOOLTIP": "tooltip - Describes the 'else if' subblock during [https://github.com/google/blockly/wiki/IfElse#block-modification if block modification].",
"CONTROLS_IF_ELSE_TOOLTIP": "tooltip - Describes the 'else' subblock during [https://github.com/google/blockly/wiki/IfElse#block-modification if block modification].",
"IOS_OK": "button text - Text on a button inside a dialogue window, which will accept or acknowledge the contents of the dialogue when pressed.\n{{Identical|OK}}",
"IOS_CANCEL": "button text - Text on a button inside a dialogue window, which will close or cancel the dialogue when pressed.\n{{Identical|Cancel}}",
"IOS_ERROR": "alert - Title text for an error dialogue.\n{{Identical|Error}}",
"IOS_PROCEDURES_INPUTS": "header text - Title of a section that displays a list of parameters (aka. 'inputs') that have been defined for a procedure. This is used inside a dialogue window to configure a procedure.\n{{Identical|Input}}",
"IOS_PROCEDURES_ADD_INPUT": "button text - Text on a button which will add a parameter (aka. 'input') to a procedure. This is used inside a dialogue window to configure a procedure. NOTE: The '+' should be preserved at the beginning of the text.",
"IOS_PROCEDURES_ALLOW_STATEMENTS": "option text - Text describing an option to allow statements to be added within a procedure. This is used inside a dialogue window to configure a procedure.",
"IOS_PROCEDURES_DUPLICATE_INPUTS_ERROR": "alert - Error message when duplicate parameters (aka. 'inputs') have been defined on a procedure. This is used inside a dialogue window to configure procedure parameters.",
"IOS_VARIABLES_ADD_VARIABLE": "button text - Text on a button which will open a variable creation dialogue when pressed. NOTE: The '+' should be preserved at the beginning of the text.",
"IOS_VARIABLES_ADD_BUTTON": "button text - Text on a button inside a variable creation dialogue, which will add a variable when pressed.\n{{Identical|Add}}",
"IOS_VARIABLES_RENAME_BUTTON": "button text - Text on a button inside a variable rename dialogue, which will rename a variable when pressed.\n{{Identical|Rename}}",
"IOS_VARIABLES_DELETE_BUTTON": "button text - Text on a button inside a variable deletion dialogue, which will delete a variable when pressed.\n{{Identical|Delete}}",
"IOS_VARIABLES_VARIABLE_NAME": "placeholder text - Placeholder text used inside a text input, where a variable name should be entered.",
"IOS_VARIABLES_EMPTY_NAME_ERROR": "alert - Error message that is displayed when the user attempts to create a variable without a name.",
"LOGIC_COMPARE_HELPURL": "{{Optional}} url - Information about comparisons.",
"LOGIC_COMPARE_TOOLTIP_EQ": "tooltip - Describes the equals (=) block.",
"LOGIC_COMPARE_TOOLTIP_NEQ": "tooltip - Describes the not equals (≠) block.",
Expand Down

0 comments on commit 500853a

Please sign in to comment.