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

Add check mark to singleSelection EuiComboBox #2890

Merged
merged 8 commits into from
Feb 24, 2020

Conversation

andreadelrio
Copy link
Contributor

Summary

This PR adds a check mark to the singleSelection combo box. To do this I enabled showIcons in EuiFilterSelectItem when singleSelection is true and hid the cross icon using CSS.

combo-single

  • Checkbox in combo box with renderOption
    image

Fixes #2808

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] 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

@andreadelrio andreadelrio requested a review from cchaos February 21, 2020 01:57
@kibanamachine
Copy link

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

@dimitropoulos
Copy link
Contributor

@andreadelrio is there any chance I can convince you to wait on merging this until #2838 is in? I'd be happy to rebase this PR for you once #2838 is merged (which, could be tomorrow, maybe? It's pretty close, I think).

It'll be much easier to rebase this off of #2838 than to do the reverse.

@thompsongl
Copy link
Contributor

@andreadelrio @dimitropoulos I agree that waiting is a good idea. We'll make sure the wait isn't long and that any conflicts are resolved for you

Comment on lines 30 to 32
.euiFilterSelectItem__crossIcon {
visibility: hidden; // hiding cross icon in single selection combo box
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@andreadelrio I'm confused by this one. Can you explain why the cross would show up in singleSelection combo boxes and why it'd be necessary to force hide it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, I was overcomplicating things, passing null to checked was enough. I made the changes.

@kibanamachine
Copy link

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

@cchaos
Copy link
Contributor

cchaos commented Feb 21, 2020

Talked with @andreadelrio about this and the behavior is a little odd where the icon only shows on the currently focused item, not the currently selected item.

Screen Recording 2020-02-21 at 02 20 PM

She's looking into it.

@andreadelrio
Copy link
Contributor Author

@cchaos pushed changes based on your PR

I replaced let checked = activeOptionIndex === index ? 'on' : null; with let checked; as I think that comparison was unnecessary and we really only need the definition of checked we're doing inside the if:

          let checked;
          if (singleSelection) {
            checked =
              selectedOptions.length && selectedOptions[0].label === label
                ? 'on'
                : null;
          }

How things are working now:

combo-single-new

@kibanamachine
Copy link

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

@snide
Copy link
Contributor

snide commented Feb 21, 2020

Just passing through. When in single selection mode this looks great 🎉 . My guess is we shouldn't leave room for the unused checks in multi-select mode.

Before

image

After

image

@andreadelrio
Copy link
Contributor Author

Just passing through. When in single selection mode this looks great 🎉 . My guess is we shouldn't leave room for the unused checks in multi-select mode.

Before

image

After

image

@snide thanks for catching that! Just pushed a fix.

@cchaos
Copy link
Contributor

cchaos commented Feb 21, 2020

I replaced let checked = activeOptionIndex === index ? 'on' : null; with let checked; as I think that comparison was unnecessary and we really only need the definition of checked we're doing inside the if

Ahh I didn't realize the original ternary was from this PR and not from master. 👍

@kibanamachine
Copy link

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

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.

Looks great! I tested (Chrome only) in all the docs examples to make sure it works with the different rendering options and it does. Much better experience for single selection. 💯

@cchaos
Copy link
Contributor

cchaos commented Feb 24, 2020

@andreadelrio Reminder though that we'll want to wait until the TS conversion of EuiComboBox PR #2838 gets merged first before merging this one.

@thompsongl
Copy link
Contributor

^ I'm going to merge the TS conversion PR shortly and then resolve any conflicts here

selectedOptions.length && selectedOptions[0].label === label
? 'on'
: null;
let checked: 'on' | 'off' = 'off';
Copy link
Contributor

Choose a reason for hiding this comment

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

@thompsongl I don't think this is correct. off would mean the icon shows a cross instead of no icon. It should be undefined or on.

Copy link
Contributor

Choose a reason for hiding this comment

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

Screen Shot 2020-02-24 at 11 32 54 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok. Good catch

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@andreadelrio andreadelrio merged commit dbdf016 into elastic:master Feb 24, 2020
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 should show check mark for single select options
6 participants