Skip to content

Default selected element gets lost after closing #1371

@fritzmg

Description

@fritzmg

Describe the bug
If you have a <select> where an <option> has selected="selected" by default and then you open that Choices select, close it again without having selected a new option and then open it again, the default selection gets "lost".

To Reproduce
This can be reproduced with one of the examples on https://choices-js.github.io/Choices/. Specifically, go down to the Form interaction example and do the following on the first form:

  1. Open the select.
  2. Press arrow key down to select "Option 3".
  3. Close the select via Esc or by clicking outside.
  4. Open the select again.
  5. Press arrow key down to select "Option 3".

It actually selects "Option 1".

Conversely you can also do the following:

  1. Open the select.
  2. Press arrow key down to select "Option 3".
  3. Confirm the "Option 3" selection with Enter.
  4. Open the select again.
  5. Press arrow key down to select "Option 4".

It actually selects "Option 1".

Expected behavior
Any time when opening the select, the currently selected item should coincide with the "active" item. Not just when the select is opened for the first time after a page load.

Choices version and bundle

  • Version: 11.2.0

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Firefox 147.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions