From 20001aa473d315ae2913ea0273c1af02c85af9f6 Mon Sep 17 00:00:00 2001 From: "Evan W. Patton" Date: Tue, 23 May 2017 10:34:42 -0400 Subject: [PATCH] Fix FieldTextInput lack of Change event FieldTextInput was not triggering a Change event and this prevented an onWorkspaceChanged event from firing in the BlocklyPanel. This commit separates the semantics of the text and value getter/setters so that updates to the text in onHtmlInputChange handler do not prevent an event being triggered in setValue() after the user commits the change. --- core/field_textinput.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/field_textinput.js b/core/field_textinput.js index 70f5a7a14..25142448d 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -66,6 +66,13 @@ Blockly.FieldTextInput.prototype.CURSOR = 'text'; */ Blockly.FieldTextInput.prototype.spellcheck_ = true; +/** + * The value of the field. + * @type {?string} + * @private + */ +Blockly.FieldTextInput.prototype.value_ = null; + /** * Close the input widget if this input is being deleted. */ @@ -92,6 +99,18 @@ Blockly.FieldTextInput.prototype.setValue = function(newValue) { } } Blockly.Field.prototype.setValue.call(this, newValue); + if (newValue !== null) { + this.value_ = newValue; + } +}; + +/** + * Get the value of this field. + * @returns {?string} + * @override + */ +Blockly.FieldTextInput.prototype.getValue = function() { + return this.value_; }; /**