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

SelectableList: add optional key property to options prop #2608

Conversation

mbondyra
Copy link
Contributor

@mbondyra mbondyra commented Dec 9, 2019

Summary

Fixes #2605

This is a proposed solution for fixing the React warning about duplicate keys for SelectableList if we pass two identical labels. The situation happens eg. for Index Pattern Chooser in Lens if index pattern was imported from Saved Object and the identically named index pattern existed in the app.

Adding optional prop 'key' for Option Interface would allow having two different objects with identical labels without throwing the warning.

Still, the PR doesn't fix the problem of differentiating two identically labelled objects from a user perspective.

Checklist

  • Checked in dark mode
  • Checked in mobile
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • Added documentation examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Thanks @mbondyra for starting this PR.

You'll need to also add a changelog entry (last checklist item in the PR summary). You should be able to follow suit from the other items. Just make sure the entry it past tense.

src/components/selectable/types.tsx Show resolved Hide resolved
src/components/selectable/types.tsx Show resolved Hide resolved
@mbondyra
Copy link
Contributor Author

mbondyra commented Dec 9, 2019

@cchaos I added the changelog note. If it can be grammatically improved don't hesitate to add a suggestion 🙏

@mbondyra mbondyra requested a review from cchaos December 9, 2019 16:53
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Tested in Chrome, it works correctly. 👍

Just one more comment for the changelog.

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Changes LGTM; pulled and tested locally

@mbondyra mbondyra force-pushed the IS-2605_add_optional-key-prop-to-selectable-options branch from 39cdf44 to 09aabe0 Compare December 10, 2019 10:13
@mbondyra mbondyra changed the title SelectableList: add optional key property to options SelectableList: add optional key property to options prop Dec 10, 2019
@mbondyra mbondyra merged commit f3fcd11 into elastic:master Dec 10, 2019
@mbondyra mbondyra deleted the IS-2605_add_optional-key-prop-to-selectable-options branch December 10, 2019 10:34
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

Successfully merging this pull request may close these issues.

SelectableList: duplicate key error if there are two identical labels for options
3 participants