Merge pull request #2577 from BeksOmega/fixes/doValueInvalid

Added Sending the Bad Value to doValueInvalid
This commit is contained in:
alschmiedt
2019-06-24 16:09:20 -07:00
committed by GitHub
3 changed files with 12 additions and 19 deletions

View File

@@ -789,16 +789,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;
};
@@ -837,12 +837,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 {*} _invalidValue The input value that was determined to be invalid.
* @protected
*/
Blockly.Field.prototype.doValueInvalid_ = function() {
Blockly.Field.prototype.doValueInvalid_ = function(_invalidValue) {
// NOP
};

View File

@@ -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.

View File

@@ -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 {*} _invalidValue 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(_invalidValue) {
if (this.isBeingEdited_) {
this.isTextValid_ = false;
var oldValue = this.value_;