Skip to content

[select] Support arbitrary object value types #2586

Description

@atomiks

Bug report

Current behavior

Only primitive string/number types are properly supported despite value being typed any. The Select.Root items prop and form value can't resolve the value or label from object value items.

Combobox has itemToLabel/String and itemToValue props to resolve the display and form submission value from the object value

Expected behavior

<Select.Item value={object}> should be properly supported

This reduces or prevents the need to map data to the conforming value/label format before rendering it

const items = [
  { id: 'test', name: 'Test' }
];

<Select.Root 
  defaultValue={items[0]} 
  items={items}
  itemToLabel={(item) => item.name} {/* <Select.Value> */}
  itemToValue={(item) => item.id} {/* hidden input value */}
>
[...] <Select.Item value={item}>

Base UI version

1.0.0-beta.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: selectChanges related to the select component.type: bugIt doesn't behave as expected.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions