Closed lenocin closed 2 months ago
Hi @lenocin .
Thanks for you feedback, if I understand correctly you want a way to support a type of Options[]
instead of having the string[]
.
But I wanted to ask you of why like you want to use it like that , you can totally use the id for db as a key and the value gonna be whatever value you have in the returned array that you have.
@BelkacemYerfa I had exactly the same problem. If I want to change both the label inside the dropdown when selecting new elements and label inside the Badge, I need to modify the component like @lenocin suggests.
It does not make much sense to not have the text inside the
Otherwise, I like it the best from all the shadcn based multiselect components, good job!
Hi @jakubjenis
Thanks for your feedback, i understand the current issue that you're facing now. We gonna introduce the fix in the upcoming release.
Great stuff!
Another option is to pass a Record<string, string>
with the value to label mapping:
...
const MultiSelectorTrigger = forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & { valueLabels: Record<string, string> }
>(({ className, children, valueLabels, ...props }, ref) => {
...
...
<span className="text-xs">{valueLabels[item]}</span>
...
<span className="sr-only">Remove {valueLabels[item]} option</span>
...
This is better that doing the find for every value.
Since my "key" is a database Id, it wasn't feasable to use the component as is (I certainly did not want to display db ids as the selected items)
So made this change which does the trick for me: