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

MultiSelect warning when using groups along with numeric values #1153

Closed
baba43 opened this issue Apr 1, 2022 · 3 comments
Closed

MultiSelect warning when using groups along with numeric values #1153

baba43 opened this issue Apr 1, 2022 · 3 comments

Comments

@baba43
Copy link

baba43 commented Apr 1, 2022

What package has an issue

@mantine/core

Describe the bug

This is the code from the docs:

<MultiSelect
    label="Your favorite Rick and Morty character"
    placeholder="Pick all that you like"
    data={[
      { value: 'rick', label: 'Rick', group: 'Used to be a pickle' },
      { value: 'morty', label: 'Morty', group: 'Never was a pickle' },
      { value: 'beth', label: 'Beth', group: 'Never was a pickle' },
      { value: 'summer', label: 'Summer', group: 'Never was a pickle' },
    ]}
/>

When using numeric values (stringified) React will show up an error:

<MultiSelect
  label="Your favorite Rick and Morty character"
  placeholder="Pick all that you like"
  data={[
    { value: "1", label: "Rick", group: "Used to be a pickle" },
    { value: "2", label: "Morty", group: "Never was a pickle" },
    { value: "3", label: "Beth", group: "Never was a pickle" },
    { value: "4", label: "Summer", group: "Never was a pickle" },
  ]}
/>
Warning: Encountered two children with the same key, `1`. 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 warning only occurs when using groups.

In which browser did the problem occur

All

If possible, please include a link to a codesandbox with the reproduced problem

No need

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Possible fix

I guess there is an issue in Key generation but I did not look into the code yet.

@baba43 baba43 added the bug label Apr 1, 2022
@baba43
Copy link
Author

baba43 commented Apr 1, 2022

This also leads to wrong UI rendering after selecting items, so it might get a real issue.

@rtivital
Copy link
Member

rtivital commented Apr 1, 2022

Thanks for reporting, it will be fixed in next patch

rtivital added a commit that referenced this issue Apr 2, 2022
@rtivital
Copy link
Member

rtivital commented Apr 3, 2022

Fixed in 4.1.2

@rtivital rtivital closed this as completed Apr 3, 2022
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

2 participants