Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DualListSelector: support list of objects as options #6213

Closed
Tracked by #8700
xprazak2 opened this issue Aug 23, 2021 · 9 comments · Fixed by #9901
Closed
Tracked by #8700

DualListSelector: support list of objects as options #6213

xprazak2 opened this issue Aug 23, 2021 · 9 comments · Fixed by #9901
Assignees
Labels

Comments

@xprazak2
Copy link
Contributor

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

@tlabaj
Copy link
Contributor

tlabaj commented Oct 1, 2021

cc @nicolethoen

@tlabaj tlabaj added this to the Prioritized Backlog milestone Oct 7, 2021
@nicolethoen nicolethoen self-assigned this Oct 8, 2021
@stale
Copy link

stale bot commented Dec 7, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label Dec 7, 2021
@nicolethoen
Copy link
Contributor

I think this can still happen - @xprazak2 is this still something you need?

@stale stale bot removed the wontfix label Dec 8, 2021
@xprazak2
Copy link
Contributor Author

xprazak2 commented Dec 9, 2021

@nicolethoen, there is no urgent need, it is an enhancement that would make it easier to use the component.

@stale
Copy link

stale bot commented Feb 7, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label Feb 7, 2022
@stale stale bot closed this as completed Feb 21, 2022
Repository owner moved this from Backlog to Done in PatternFly Issues Feb 21, 2022
@nicolethoen nicolethoen reopened this Mar 16, 2022
@stale stale bot removed the wontfix label Mar 16, 2022
@nicolethoen
Copy link
Contributor

For now, there is a way to pass more data to available or chosen options in a dynamically generated DualListSelector.
You will always have more flexibility if you build your Dual List Selector composably, but I've created a code sandbox to demonstrate how to pass more information to your Dual List Selector items.
https://codesandbox.io/s/nifty-wave-z4ppuj?file=/index.js

@stale
Copy link

stale bot commented May 24, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label May 24, 2022
@stale stale bot closed this as completed Jun 7, 2022
@guillaumevincent
Copy link
Contributor

Can we reopen this issue ?

Basically the solution proposed is: Build an array of React Node and hide the id in the data-id property.

availableOptions: available.map(a=>(<span data-id={a.id}>{a.name}</span>))

Then in the onListChange get the id yourself and rebuild the array of objects.

const chosenOptions = newChosenOptions.map((o) => availableOptionsByIds[o.props["data-id"]]);

It seems a little hacky to me. And it adds extra work in my code because I need to create and save availableOptionsByIds apart instead of using availableOptions directly.

--

One solution for me is to use (like in other components like Patternfly Select component) an array of string or an array of Object with a toString method.

Or define an API saying, if you pass an array of object, you need a 'name' properties.

@nicolethoen nicolethoen reopened this Jun 13, 2022
@stale stale bot removed the wontfix label Jun 13, 2022
@nicolethoen nicolethoen moved this from Done to Not started in PatternFly Issues Jun 16, 2022
@nicolethoen nicolethoen moved this from Not started to In Progress in PatternFly Issues Jul 12, 2022
@mcarrano mcarrano modified the milestones: 2022.09, 2022.10 Jul 12, 2022
@mcarrano mcarrano modified the milestones: 2022.15, 2022.16 Nov 11, 2022
@nicolethoen nicolethoen removed this from the 2022.16 milestone Nov 15, 2022
@tlabaj tlabaj added this to the 2023.02 milestone Dec 7, 2022
@nicolethoen nicolethoen modified the milestones: 2023.02, Post v5 priority Feb 14, 2023
@nicolethoen nicolethoen removed the Breaking change 💥 this change requires a major release and has API changes. label Feb 15, 2023
@nicolethoen nicolethoen removed their assignment Feb 15, 2023
@stale
Copy link

stale bot commented Apr 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label Apr 18, 2023
@mcarrano mcarrano added DevX and removed Feature labels Jun 12, 2023
@nicolethoen nicolethoen moved this from In Progress to Not started in PatternFly Issues Aug 2, 2023
@mfrances17 mfrances17 self-assigned this Oct 10, 2023
@tlabaj tlabaj modified the milestones: Prioritized Backlog, 2023.Q4 Oct 19, 2023
@mfrances17 mfrances17 moved this from Not started to In Progress in PatternFly Issues Dec 19, 2023
@wise-king-sullyman wise-king-sullyman removed this from the 2023.Q4 milestone Jan 11, 2024
@mfrances17 mfrances17 moved this from In Progress to Not started in PatternFly Issues Jan 18, 2024
@mfrances17 mfrances17 moved this from Not started to In Progress in PatternFly Issues Feb 15, 2024
@mfrances17 mfrances17 moved this from In Progress to PR Review in PatternFly Issues Feb 15, 2024
@github-project-automation github-project-automation bot moved this from PR Review to Done in PatternFly Issues Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants