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

Select - 2 Items with same value shows same-key error in console #515

Open
penx opened this issue May 30, 2024 · 0 comments
Open

Select - 2 Items with same value shows same-key error in console #515

penx opened this issue May 30, 2024 · 0 comments

Comments

@penx
Copy link
Contributor

penx commented May 30, 2024

I have a list of languages in a Select. I want to feature some options at the top of the Select but these options also appear alphabetically lower down with the same label and value.

When I had 2 items to a select with the same value but a different key as follows:

<form>
  <Theme>
    <Select.Root defaultValue="a">
      <Select.Trigger />
      <Select.Content>
        <Select.Item key="featured-a" value="a">
          Featured A
        </Select.Item>
        <Select.Item key="a" value="a">
          A
        </Select.Item>
      </Select.Content>
    </Select.Root>
  </Theme>
</form>

https://github.com/penx/radix-select-multiple-issue

Then an error appears in the console:

Warning: Encountered two children with the same key, a. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version

This only occurs when the Select is a descendent of a form element. I cannot recreate the issue using Radiix Primitives Select directly.

@penx penx changed the title Select - 2 Items with same value shows error in console Select - 2 Items with same value shows same-key error in console Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant