Skip to content

Commit

Permalink
fix: Don't try to set text fields to null on cancel (google#5690)
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.

Causes errors in the custom note field which inherits from FieldTextInput.  Detected in Blockly Games Music.
  • Loading branch information
NeilFraser authored Nov 8, 2021
1 parent c75e944 commit eca5ee2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/field_textinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@ FieldTextInput.prototype.showEditor_ = function(_opt_e, opt_quietInput) {
*/
FieldTextInput.prototype.showPromptEditor_ = function() {
dialog.prompt(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

0 comments on commit eca5ee2

Please sign in to comment.