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

fix(ComboBox): ensure unique keys #4999

Merged
merged 6 commits into from
Jan 11, 2020

Conversation

asudoh
Copy link
Contributor

@asudoh asudoh commented Jan 10, 2020

This change switches React keys of the items of <Dropdown> as well as the one of <ComboBox> from their text content to provided keys in data.

This is applying the corresponding logic of <MultiSelect>.
In this way duplicate item text won't yeild duplicate React keys.

Fixes #4969.

Changelog

Changed

  • The React key generation logic of <Dropdown> as well as the one of <ComboBox> from their text content to provided keys in data.

Testing / Reviewing

Testing should make sure <Dropdown> and <ComboBox> are not broken.

This change swiches React `key`s of the items of `<Dropdown>` as well
as the one of `<ComboBox>` from their text content to provided keys in
data.

This is applying the corresponding logic of `<MultiSelect>`.
In this way duplicate item text won't yeild duplicate React keys.

Fixes carbon-design-system#4969.
@netlify
Copy link

netlify bot commented Jan 10, 2020

Deploy preview for the-carbon-components ready!

Built with commit 0a657cd

https://deploy-preview-4999--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Jan 10, 2020

Deploy preview for carbon-elements ready!

Built with commit 0a657cd

https://deploy-preview-4999--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Jan 10, 2020

Deploy preview for carbon-components-react ready!

Built with commit 0a657cd

https://deploy-preview-4999--carbon-components-react.netlify.com

Copy link
Member

@emyarod emyarod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, tested with the sandbox code in the original issue and no duplicate key warnings are emitted

Copy link
Contributor

@abbeyhrt abbeyhrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make MenuItem key in ComboBox to use unique id first
4 participants