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

Encountered two children with the same key warning - Select with creatable prop #1662

Closed
osolliec opened this issue Jun 21, 2022 · 3 comments
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)

Comments

@osolliec
Copy link

What package has an issue

@mantine/core

Describe the bug

Warning of duplicate keys when you hover on options if you have the creatable prop enabled.
image

In which browser did the problem occur

Chrome

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

https://codesandbox.io/s/cocky-currying-hlkgei?file=/src/App.tsx

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

No response

@osolliec osolliec added the bug label Jun 21, 2022
@rtivital rtivital added the help wanted Contributions from community are welcome label Jun 21, 2022
@jpemberton94
Copy link

The creatable div's key is assigned the value of the Select input field. This will happen any time the value of the Select matches an existing value in the SelectList. Appending '-creatable' to the key would be the easiest way to bypass this warning.

This does beg a larger question... Does it make sense for the Select component w/ creatable to allow the creation of an item which already exists in the list? It may make more sense that the creatable div doesn't render at all if the value already exists in the list

@rtivital
Copy link
Member

shouldCreate function determines whether creatable option should be displayed in the list, in the provided sandbox it always returns true, and thus creatable option is always rendered.

@rtivital rtivital removed the help wanted Contributions from community are welcome label Jun 24, 2022
@rtivital rtivital added Fixed patch Completed issues that will be published with next patch (1.0.X) and removed bug labels Aug 11, 2022
rtivital added a commit that referenced this issue Aug 12, 2022
@rtivital
Copy link
Member

Fixed in 5.1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

No branches or pull requests

3 participants