Choices-js/Choices

The config.choices is empty on `11.0.2`

Closed this issue · 3 comments

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

  • Version: v11.0.2

Desktop (please complete the following information):

  • OS: Windows 11
  • Chrome
  • 29.0.6668.90
Xon commented

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.

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

Yes, that will be populated as expected