diff --git a/core/field.js b/core/field.js index 7c50b46a6..3ad8d3cfb 100644 --- a/core/field.js +++ b/core/field.js @@ -779,16 +779,16 @@ Blockly.Field.prototype.setValue = function(newValue) { */ Blockly.Field.prototype.processValidation_ = function(newValue, validatedValue) { - if (validatedValue !== undefined) { - newValue = validatedValue; - } - if (newValue === null) { - this.doValueInvalid_(); + if (validatedValue === null) { + this.doValueInvalid_(newValue); if (this.isDirty_) { this.forceRerender(); } return Error(); } + if (validatedValue !== undefined) { + newValue = validatedValue; + } return newValue; }; @@ -827,12 +827,13 @@ Blockly.Field.prototype.doValueUpdate_ = function(newValue) { }; /** - * Used to notify the field an invalid value was input. Can be overiden by + * Used to notify the field an invalid value was input. Can be overidden by * subclasses, see FieldTextInput. * No-op by default. + * @param {*} _newValue The input value that was determined to be invalid. * @protected */ -Blockly.Field.prototype.doValueInvalid_ = function() { +Blockly.Field.prototype.doValueInvalid_ = function(_newValue) { // NOP }; diff --git a/core/field_date.js b/core/field_date.js index 20290fa68..1586de38a 100644 --- a/core/field_date.js +++ b/core/field_date.js @@ -116,17 +116,6 @@ Blockly.FieldDate.prototype.doClassValidation_ = function(newValue) { return newValue; }; -/** - * Called when the given value is invalid. If the picker is shown, set - * isDirty to true so that it gets reset to the previous selection. - * @protected - */ -Blockly.FieldDate.prototype.doValueInvalid_ = function() { - if (this.picker_) { - this.isDirty_ = true; - } -}; - /** * Render the field. If the picker is shown make sure it has the current * date selected. diff --git a/core/field_textinput.js b/core/field_textinput.js index a79d55e03..495d7b447 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -115,9 +115,12 @@ Blockly.FieldTextInput.prototype.doClassValidation_ = function(newValue) { * Called by setValue if the text input is not valid. If the field is * currently being edited it reverts value of the field to the previous * value while allowing the display text to be handled by the htmlInput_. + * @param {*} _newValue The input value that was determined to be invalid. + * This is not used by the text input because its display value is stored on + * the htmlInput_. * @protected */ -Blockly.FieldTextInput.prototype.doValueInvalid_ = function() { +Blockly.FieldTextInput.prototype.doValueInvalid_ = function(_newValue) { if (this.isBeingEdited_) { this.isTextValid_ = false; var oldValue = this.value_;