1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Ensure TypedInput Change event is passed type/value properties

Fixes #2883
This commit is contained in:
Nick O'Leary 2021-02-25 13:03:31 +00:00
parent 0be82d964e
commit 5f8804c25c
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 24 additions and 10 deletions

View File

@ -342,7 +342,7 @@
this.input.on('change', function() { this.input.on('change', function() {
that.validate(); that.validate();
that.element.val(that.value()); that.element.val(that.value());
that.element.trigger('change',that.propertyType,that.value()); that.element.trigger('change',[that.propertyType,that.value()]);
}); });
this.input.on('keydown', function(evt) { this.input.on('keydown', function(evt) {
if (evt.keyCode >= 37 && evt.keyCode <= 40) { if (evt.keyCode >= 37 && evt.keyCode <= 40) {
@ -606,7 +606,7 @@
} }
if (opt.hasValue) { if (opt.hasValue) {
this.optionValue = o.value; this.optionValue = o.value;
this.input.trigger('change',this.propertyType,this.value()); this.input.trigger('change',[this.propertyType,this.value()]);
} }
} else { } else {
this.optionSelectLabel.text(o.length+" selected"); this.optionSelectLabel.text(o.length+" selected");
@ -699,7 +699,7 @@
opt.valueLabel.call(this,this.valueLabelContainer,value); opt.valueLabel.call(this,this.valueLabelContainer,value);
} }
} }
this.input.trigger('change',this.type(),value); this.input.trigger('change',[this.type(),value]);
} }
}, },
type: function(type) { type: function(type) {
@ -864,7 +864,7 @@
}); });
} }
this._trigger("typechange",null,this.propertyType); this._trigger("typechange",null,this.propertyType);
this.input.trigger('change',this.propertyType,this.value()); this.input.trigger('change',[this.propertyType,this.value()]);
} else { } else {
if (this.optionSelectTrigger) { if (this.optionSelectTrigger) {
this.optionSelectTrigger.hide(); this.optionSelectTrigger.hide();
@ -934,7 +934,7 @@
} }
} }
this._trigger("typechange",null,this.propertyType); this._trigger("typechange",null,this.propertyType);
this.input.trigger('change',this.propertyType,this.value()); this.input.trigger('change',[this.propertyType,this.value()]);
} }
} }
} }

View File

@ -356,14 +356,14 @@ RED.editor = (function() {
function attachPropertyChangeHandler(node,definition,property,prefix) { function attachPropertyChangeHandler(node,definition,property,prefix) {
var input = $("#"+prefix+"-"+property); var input = $("#"+prefix+"-"+property);
if (definition !== undefined && "format" in definition[property] && definition[property].format !== "" && input[0].nodeName === "DIV") { if (definition !== undefined && "format" in definition[property] && definition[property].format !== "" && input[0].nodeName === "DIV") {
$("#"+prefix+"-"+property).on('change keyup', function(event,skipValidation) { $("#"+prefix+"-"+property).on('change keyup', function(event,) {
if (!skipValidation) { if (!$(this).attr("skipValidation")) {
validateNodeEditor(node,prefix); validateNodeEditor(node,prefix);
} }
}); });
} else { } else {
$("#"+prefix+"-"+property).on("change", function(event,skipValidation) { $("#"+prefix+"-"+property).on("change", function(event,skipValidation) {
if (!skipValidation) { if (!$(this).attr("skipValidation")) {
validateNodeEditor(node,prefix); validateNodeEditor(node,prefix);
} }
}); });
@ -476,13 +476,27 @@ RED.editor = (function() {
// to prevent full node validation from being triggered each time // to prevent full node validation from being triggered each time
for (var d in definition.defaults) { for (var d in definition.defaults) {
if (definition.defaults.hasOwnProperty(d)) { if (definition.defaults.hasOwnProperty(d)) {
$("#"+prefix+"-"+d).trigger("change",[true]); var el = $("#"+prefix+"-"+d);
el.attr("skipValidation", true);
if (el.data("noderedTypedInput") !== undefined) {
el.trigger("change",[el.typedInput('type'),el.typedInput('value')]);
} else {
el.trigger("change");
}
el.removeAttr("skipValidation");
} }
} }
if (definition.credentials) { if (definition.credentials) {
for (d in definition.credentials) { for (d in definition.credentials) {
if (definition.credentials.hasOwnProperty(d)) { if (definition.credentials.hasOwnProperty(d)) {
$("#"+prefix+"-"+d).trigger("change",[true]); var el = $("#"+prefix+"-"+d);
el.attr("skipValidation", true);
if (el.data("noderedTypedInput") !== undefined) {
el.trigger("change",[el.typedInput('type'),el.typedInput('value')]);
} else {
el.trigger("change");
}
el.removeAttr("skipValidation");
} }
} }
} }