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

**URL:** <https://discourse.nodered.org/t/bug-in-select-multiple-in-node-property-editor-doesnt-always-save-changes/6315>\
**Category:** Core Development\
**Created:** [2 January 2019 13:00 UTC](https://discourse.nodered.org/t/bug-in-select-multiple-in-node-property-editor-doesnt-always-save-changes/6315 "2019-01-02T13:00:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![myplacedk](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myplacedk/32/3678_2.png) [@myplacedk](https://discourse.nodered.org/u/myplacedk)\
**Post date:** [2 January 2019 13:00 UTC](https://discourse.nodered.org/t/bug-in-select-multiple-in-node-property-editor-doesnt-always-save-changes/6315/1 "2019-01-02T13:00:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [2 January 2019 18:13 UTC](https://discourse.nodered.org/t/bug-in-select-multiple-in-node-property-editor-doesnt-always-save-changes/6315/2 "2019-01-02T18:13:29Z")

</div>

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