Add metadata to Command items #1187
MichaelBrunn3r
started this conversation in
Feature Requests / Ideas
Replies: 1 comment 4 replies
|
The To determine which one is selected, you can use the {#each trafficLights as [name, value]}
<Command.Item onSelect={() => {
mySelectedValue = trafficLights[name]
}} />
{/each}
{#each colors as [name, value]}
<Command.Item onSelect={() => {
mySelectedValue = colors[name]
}} />
{/each} |
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
My main issue is on how to find out which item is currently selected and how to handle duplicates.
A simplified example:
If
value === "red", how do I determine if the currently selected item is a color or a traffic-light state?My current fix would be, to add more information to the
valueprop of each item:... {#each Object.entries(colors) as [name, value] } <Command.Item value={"color:" + name}>{name}: {value}</Command.Item> {/each} ... {#each Object.entries(trafficLightStates) as [state, value] } <Command.Item value={"trafficLight:" + name}>{name}: {value}</Command.Item> {/each} ...This way,
color:redandtrafficLight:redcan be differentiated. Luckily the search algorithm is fuzzy and we have keywords, otherwise this approach would interfere with searching. But are there drawbacks I haven't thought of yet?I'm not sure if this is the right solution to go with or if it would be beneficial to add metadata to each item instead:
All reactions