Potential bug with dmx-bind:value for select

Reposting here from yesterday as I thought it was resolved but not so. I have made some change per some suggestions on the forum but same problem at this stage.

Wappler: 6.5.2
Node JS

  1. I have a modal, that on open calls an API to get a list of medical conditions. This is not connected to a a form in the modal, it runs as a seperate API action.
  2. This list populates a select element (this works fine, with UUID as value and a name)
  3. The select element has a “none” option hard coded item (though its not selected by default)
  4. The select has a dmx-bind:value to a UUID which it gets from another endpoint. This endpoint is called when the page loads (so way before the modal is opened by the user)
  5. When opening the modal for the first time, the correct value is selected and shown in the select dropdown.
  6. When closing the modal and opening it again, or resetting the form (created a test button on the modal), the select dropdown value is set to “None” instead of the correct value.

More info

I think this might be a bug with setting the default “selected” option, but if anyone has any guidance that would be awesome. I think the expected behaviour should be to re-select the correct dmx-bind:value each time the modal is opened / form is reset. As I understand it, the selected default value should be that from the dmx-bind:value. If I change the selection, hit reset form, it goes back to the dmx-bind:value.

Doing some more research on this, when the item appears to be selected per screenshot below, the item isn’t actually set to “selected” in the HTMl code (see screenshots below).

Any help would be appreciated thanks :slight_smile:

Could you check if the following update fixes it.

dmxAppConnect.zip (116.2 KB)

Thanks for your help @patrick . Not quite, the “none” option (see previous screenshot) is now not set to “selected”, but the dmx-bind:value option that should have “selected” on it does not. So the same issue occurs.

Hi @patrick any further update on this? Just wanted to check in.

Did you try the latest App Connect 2.0.4 included in Wappler 6.5.4?

Thanks, yeah I did try on 6.5.4 but the issue is still there.

i think this is related.

Opening a modal does nothing with the form controls. Whit a form reset it should reset the value to the one set in the value attribute or the dmx-bind:value attribute.

The attributes do not always reflect the actual state of the element. With a select changing the selection does not update the attributes in the DOM while the selected property is changed. You can test this by selecting the as you have and type in the console $0.selected which will return true. $0 points to the selected element in the elements panel of devtools. $0.hasAttribute('selected') will return false and when you do that on the option element with None you get the opposite where the attribute is true and the property is false.