Skip to content

DualListSelector: support list of objects as options #6213

Closed
@xprazak2

Description

@xprazak2

Describe the issue. What is the expected and unexpected behavior?

availableOptions and chosenOptions props have the type React.ReactNode[] | DualListSelectorTreeItemData[]. When using basic select (no tree/checkboxes), I would like to pass array of objects as available and chosen options.

The use case is to separate what is presented to user for selection and how the items are identified. We often want to present a user-friendly name while keeping track of the items by id.

Please provide the steps to reproduce. Feel free to link CodeSandbox or another tool.

const available = [{ id: 'xyz', name: 'First available' }, { id: 'pqr', name: 'Second available' }]
const chosen = [{ id: 'abc', name: 'First chosen' }]

<DualListSelector
  availableOptions={available}
  chosenOptions={chosen}
/>

A posiblilty is to use a formatter function: { id: 'abx', toString: () => "Pretty name for users" }

Is this a bug or enhancement? If this issue is a bug, is this issue blocking you or is there a work-around?

Enhancement

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions