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

[EuiComboBox] Allow options to have a unique key #4048

Merged
merged 13 commits into from
Oct 6, 2020

Conversation

timroes
Copy link
Contributor

@timroes timroes commented Sep 17, 2020

Summary

Fixes #3803

This will allow EuiComboBoxItems to optionally have an id and in this case allow duplicate labels. We require this change for Kibana, to allow display displayName of fields instead of the real name, which in some cases could be duplicate.

I added a documentation section, that also states that this is not recommended to use duplicate labels.

@chandlerprall It would be great if you could check if I've forgot any place to make this work. It seems to work exactly as I want, and I tried to go through all combo box code, but a second pair of eyes would be really appreciated.

Checklist

  • [ ] Check against all themes for compatibility in both light and dark modes
  • [ ] Checked in mobile
  • [ ] Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs
  • Added documentation
  • Checked Code Sandbox works for the any docs 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

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4048/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4048/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4048/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4048/

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.

The approach looks good to me, and I was unable to break it. Added a couple small requests/thoughts.

CHANGELOG.md Outdated Show resolved Hide resolved
src-docs/src/views/combo_box/combo_box_example.js Outdated Show resolved Hide resolved
src/components/combo_box/matching_options.ts Show resolved Hide resolved
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4048/

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 & tested existing examples & the new one locally

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 the PR and the documentation example! Gots a couple of comments.

src-docs/src/views/combo_box/combo_box_example.js Outdated Show resolved Hide resolved
@@ -199,13 +203,15 @@ export const ComboBoxExample = {

<EuiSpacer />

<EuiCallOut title="No duplicate option labels allowed" color="warning">
<EuiCallOut title="Duplicate labels require an id" color="warning">
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's actually remove this entire callout now that we have a specific example section that explains this more succinctly.

};

return (
/* DisplayToggles wrapper for Docs only */
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this comment as it doesn't apply here.

Suggested change
/* DisplayToggles wrapper for Docs only */

import DuplicateOptions from './combo_box_duplicates';
const duplicateOptionsSource = require('!!raw-loader!./combo_box_duplicates');
const duplicateOptionsHtml = renderToHtml(DuplicateOptions);

This comment was marked as outdated.

</p>
),
props: { EuiComboBox },
demo: <DuplicateOptions />,

This comment was marked as resolved.

timroes and others added 2 commits September 28, 2020 11:13
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4048/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4048/

@chandlerprall
Copy link
Contributor

chandlerprall commented Sep 30, 2020

Talked with Tim, it is likely that #4072 introduces a new location this change around key vs. label will need to address, so he is holding off until that merges. The downstream source for any urgency here has shifted and is no longer an immediately pressing issue, so this delay is fine.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4048/

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.

Changing id to key solves my concerns. Thanks!

@cchaos cchaos changed the title Allow options in combo box to have an id Allow options in combo box to have a unique key Oct 6, 2020
@cchaos cchaos changed the title Allow options in combo box to have a unique key [EuiComboBox] Allow options to have a unique key Oct 6, 2020
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 look even better now :) Pulled & tested locally.

@timroes
Copy link
Contributor Author

timroes commented Oct 6, 2020

Jenkins test this (unrelated CI issue)

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4048/

@thompsongl thompsongl merged commit 2f83517 into elastic:master Oct 6, 2020
@timroes timroes deleted the fix/combo-box-ids branch October 6, 2020 15:44
kshitij86 added a commit to kshitij86/eui that referenced this pull request Nov 29, 2020
* Allow options in combo box to have an id

* Change warning in documentation

* Fix eslint error

* Added changelog entry

* Address review

* Update src-docs/src/views/combo_box/combo_box_example.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Address review feedback

* Rename id to key

* Address recently merged PRs changes

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
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.

[EuiComboBox] Allow explicit id to track selected item
5 participants