Bug in select multiple in node property editor - doesn't always save changes

In my node I have a property than can have multiple values. Easiest way to implement is a select with multiple enabled. And it almost works. When using the configuration server side, I get an array of values as expected.

However when removing all selections, the changes in that select isn't saved.

I tracked it down to this bit in editor.js:

if (input.attr('type') === "checkbox") {
    newValue = input.prop('checked');
} else if ("format" in editing_node._def.defaults[d] && editing_node._def.defaults[d].format !== "" && input[0].nodeName === "DIV") {
    newValue = input.text();
} else {
    newValue = input.val();
}
if (newValue != null) {

The problem is that in this version of jQuery, val() on a select multiple with no options selected returns null, which is then misinterpreted as no new value.

One possible solution:

  if (input.attr('type') === "checkbox") {
      newValue = input.prop('checked');
+} else if (input.prop("nodeName") === "select" && input.attr("multiple") === "multiple") {
+    newValue = input.val();
+    if (newValue == null) {
+        newValue = [];
+    }
  } else if ("format" in editing_node._def.defaults[d] && editing_node._def.defaults[d].format !== "" && input[0].nodeName === "DIV") {
      newValue = input.text();

Unfortunately I can't test the solution, as I have problems running the build, and I don't want to spend more time on that right now. I can make a PR anyway, if that would be helpful.

Hi @myplacedk - can't investigate fully at the moment, but have raised https://github.com/node-red/node-red/issues/2021 and put it in the plan for the 0.20 release.