From 6c96cde73c53c921544069ca809409b25d2c3ac6 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 5 Oct 2021 10:34:46 +0100 Subject: [PATCH] Copy previous rule type when adding rule to switch node --- .../src/js/ui/common/typedInput.js | 7 +- .../nodes/core/function/10-switch.html | 253 +++++++++--------- .../nodes/core/function/15-change.html | 2 +- 3 files changed, 135 insertions(+), 127 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js index 41c731e3b..b9754430c 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js @@ -783,14 +783,14 @@ var typeChanged = !!previousType; if (typeChanged) { - if (previousType.options) { + if (previousType.options && opt.hasValue !== true) { this.oldValues[previousType.value] = this.input.val(); } else if (previousType.hasValue === false) { this.oldValues[previousType.value] = this.input.val(); } else { this.oldValues["_"] = this.input.val(); } - if (opt.options || opt.hasValue === false) { + if ((opt.options && opt.hasValue !== true) || opt.hasValue === false) { this.input.val(this.oldValues.hasOwnProperty(opt.value)?this.oldValues[opt.value]:(opt.default||[]).join(",")) } else { this.input.val(this.oldValues.hasOwnProperty("_")?this.oldValues["_"]:(opt.default||"")) @@ -1069,6 +1069,9 @@ }, disabled: function() { return this.uiSelect.attr("disabled") === "disabled"; + }, + focus: function() { + this.input.focus(); } }); })(jQuery); diff --git a/packages/node_modules/@node-red/nodes/core/function/10-switch.html b/packages/node_modules/@node-red/nodes/core/function/10-switch.html index 6524a1030..54ca33e0f 100644 --- a/packages/node_modules/@node-red/nodes/core/function/10-switch.html +++ b/packages/node_modules/@node-red/nodes/core/function/10-switch.html @@ -17,11 +17,11 @@