Skip to content

ComboBox multi-select onChange inputs string instead of type #2865

@nsadeh

Description

@nsadeh

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

For example: ^1.7.17

What browser are you using?

Chrome

Reproduction URL

(https://github.com/nsadeh/headless-bug)

Describe your issue

TLDR; when using array types in the combobox component, I expect that a function (T[] => void) act act on T[], but instead it appears to only work on strings.

I am using combobox to create a combobox that supports multiple selections. Per the documentation, I am using an array type as input to the combobox and the onChange functions. I pass in a function that takes a list of my MultiselectOption items and is supposed to store them in state.

Strangely, the onChange function appears to only store a single field from my type, the title field. You can verify this in the console logs from the attached react script. This means that the ID field isn't captured, which is vital.

I can sort of get around this by manually using an onClick on the Option, but I lose the ability to use the Enter key that comes built-in with the combobox.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions