From eca5ee26d7159628a7d9a4fa1ce017740db736e3 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Mon, 8 Nov 2021 09:08:16 -0800 Subject: [PATCH] fix: Don't try to set text fields to null on cancel (#5690) 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. --- core/field_textinput.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/field_textinput.js b/core/field_textinput.js index 1b9a067da..294c9bbd0 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -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)); };