Hi team,
I noticed a behaviour while developing a new node and using the button
attribute
https://nodered.org/docs/creating-nodes/appearance#buttons
the node has a button defined like this
visible: function () {
return !this.changed
},
enabled: function () {
return !this.changed && this.nodeState !== 0 && this.nodeState !== 2
}
now enabled
surely returns false
. The button visually "looks" disabled, that is dimmed greyed out, and and the mouse arrow does not show as a clickable rect, however, when the rect is clicked anywhere inside the button, the action attached to the click is actually executed!
The expected behavior is that the click action is never invoked if the button is disabled.
I verified this as I have an admin API attached to button click.
Node-RED version: v3.0.2
Node.js version: v14.20.0
Update:I dont know if this is by design! I just noticed that the Inject node actually has the same behaviour. When added to the workspace, the button is disabled however it is still clickable! I dont believe it was the case in previous versions.
Here is the button definition from the core Inject node. Wondering why the onclick
function still doInject
, shouldnt this be an if ... else
instead ??
button: {
enabled: function() {
return !this.changed
},
onclick: function () {
if (this.changed) {
return RED.notify(RED._("notification.warning", { message: RED._("notification.warnings.undeployedChanges") }), "warning");
}
doInject(this);
}