You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Up to v10, updating the choices with the setChoices method and replaceOptionstrue was properly discarding the base select value if it wasn't part of the new options.
Since v11, using setChoices even with replaceOptionstrue keeps the previously selected value, even if it isn't part of the newly provided options.
Furthermore, there is no way to restore the default disabled but selected option provided to the base select element.
To Reproduce
Steps to reproduce the behaviour:
Create a new Choice instance without passing choices
The base select tag should only contain one disabled but selected option ("please make a choice")
Update the options a first time
The disabled option is properly showing as the base selected one ("please make a choice")
Select one enabled option
Update the options a second time (spreading the _presetChoices to provide the default option)
The previously selected option value remains selected
Expected behaviour
The previously selected option value shouldn't remain selected if not par of the new options values.
The default disabled option should appear as the placeholder.
Choices version and bundle
Version: [e.g. v11.0.3 choices.min.js]
Desktop
OS: MacOS, Windows
Browser: Chrome 132.0.6834.160
The text was updated successfully, but these errors were encountered:
Describe the bug
Up to v10, updating the choices with the
setChoices
method andreplaceOptions
true
was properly discarding the base select value if it wasn't part of the new options.Since v11, using
setChoices
even withreplaceOptions
true
keeps the previously selected value, even if it isn't part of the newly provided options.Furthermore, there is no way to restore the default disabled but selected option provided to the base select element.
To Reproduce
Steps to reproduce the behaviour:
Example
https://codepen.io/saeraphin/pen/ZYzNyoR
Expected behaviour
The previously selected option value shouldn't remain selected if not par of the new options values.
The default disabled option should appear as the placeholder.
Choices version and bundle
Desktop
The text was updated successfully, but these errors were encountered: