jpmorganchase / salt-ds

React UI components built with a focus on accessibility, customization and ease-of-use
https://www.saltdesignsystem.com
Apache License 2.0
133 stars 89 forks source link

[Combobox] Delimiter selection #3264

Open nathanmmiller opened 7 months ago

nathanmmiller commented 7 months ago

Area

UI Components

The problem

Combobox users should be able to paste comma-delimited things into a multiselect-combobox and have those items all immediately select. Additionally, the comma should be definable via a prop.

So for example, if a multiselect Combobox contains options of "Apple" and "Banana" and "Cherry" and a user pastes "Apple,Banana" into the box, both Apple and Banana should become selected.

If the combobox were set up with delimiter={"|"} then "Apple|Banana" would do the same thing.

The solution

The addition of a delimiter prop and also the implementation of selection based on it

Alternatives and examples

I can share examples internal to JPMC if someone pings me.

Are you a JPMorgan Chase & Co. employee?

origami-z commented 7 months ago

One potential way you can achieve through onPaste: https://stackblitz.com/edit/salt-template-vrwwch?file=App.tsx