Skip to content

setValue for select doesn't work as expected #444

Closed
@sebGH06

Description

@sebGH06

Summary

when trying to set the value of an existing select, it throw a javascript console error

Steps to Reproduce

document.addEventListener('DOMContentLoaded', function() {

    HSStaticMethods.autoInit(['select']); // Mandatory for HSSelect instance to work 

    const selectEl = document.querySelector('#mySelect');
    const selectInstance = HSSelect.getInstance(selectEl);
    console.log(selectInstance); // I can see the instance OK

    const setValueBtn = document.querySelector('#remember');

    setValueBtn.addEventListener('click', () => {

        selectInstance.setValue("always"); // Trigger the error
    });
});

Demo Link

https://preline.co/plugins/html/advanced-select.html

Expected Behavior

setValue is expected to set the value of the select

Actual Behavior

setValue trigger an error

In the console.log, I see in the instance I displayed that the value property has changed to the new value, but nothing happen on the page.

For your information, trying the close() method or open() method work perfectly, only setValue is faulty !

Screenshots

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions