Skip to content

Single select with placeholder initialization value #1337

@ebejko

Description

@ebejko

Describe the bug
When initializing a single select that has a placeholder and the possibility to remove options, the initial value of the select is the first element of the list.

To Reproduce
https://jsfiddle.net/anvf51L4/

Expected behavior
Since the value of the dropdown is manually set to '' upon selection removal, I would expect the same behavior to be replicated on initialization. The piece of code I'm referring to:

// For a select-one, if all options are deselected, the first item is selected. To set a black value, select.value needs to be set
const select = el.parentElement;
if (select && isHtmlSelectElement(select) && select.type === PassedElementTypes.SelectOne) {
select.value = '';
}

Choices version and bundle

  • Version: v11.1.0 choices.min.js

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: edge
  • Version: 139

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