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 destroy does not respect selected value. This causes issues when using with libraries like Turbo and Stimulus, where you want to destroy() when leaving the page or disconnecting the controller
As a workaround for simple inputs, I'm using this in the disconnect() controller
disconnect(){// FIXME: workaround for Choices-js/Choices#1088constselectedValues=this.choices._currentState.items.map((item)=>item.value)this.choices.destroy()selectedValues.forEach((selectedValue)=>{constoption=this.choicesTarget.querySelector(`option[value="${selectedValue}"]`)if(!option){return}option.setAttribute('selected','selected')})}
The text was updated successfully, but these errors were encountered:
Describe the bug
destroy
does not respectselected
value. This causes issues when using with libraries like Turbo and Stimulus, where you want todestroy()
when leaving the page or disconnecting the controllerTo Reproduce
Steps to reproduce the behavior:
Expected behavior
Option 3 (selected)
selectedScreenshots
n/a
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Related to #1055
As a workaround for simple inputs, I'm using this in the
disconnect()
controllerThe text was updated successfully, but these errors were encountered: