Choices-js / Choices

A vanilla JS customisable select box/text input plugin ⚡️
https://choices-js.github.io/Choices/
MIT License
6.25k stars 617 forks source link

The config.choices is empty on `11.0.2` #1217

Closed seredniy closed 1 month ago

seredniy commented 1 month ago

Describe the bug Hello!

Thank you for the excellent library and your hard work!

In our code, we used version 10.2.0 of your library. In some of our checks, we accessed instance.config.choices to get the list of choices for the current instance.

image

We recently upgraded to version 11.0.2, and now instance.config.choices appears empty.

shot_YBcKk

Currently, we are temporarily using instance._presetChoices, but I'm not sure if this is a proper and correct replacement. What exactly changed, and how should we handle this now? Thank you!

P.S. I tested it on your demo and external JSFiddle also.

To Reproduce Steps to reproduce the behavior:

  1. Install the 11.0.2 version of the library
  2. Try to get config.choices

Choices version and bundle

Desktop (please complete the following information):

Xon commented 1 month ago

instance.config.choices is the original choices passed in via the choices config option when using a <select> element.

If you want the current choices then instance._store.choices will work in v10.2.0 and v11.0.x, otherwise _presetChoices is the one gathered from the backing <select> element and any config option supplied.

seredniy commented 1 month ago

Thanks, @Xon!

I was confused because in v10.2.0, that config.choices was always filled, even when choices were not passed via the choices config option.

Anyway, I can safely use _presetChoices for now?

Xon commented 1 month ago

Yes, that will be populated as expected