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 additions #1139

Merged
merged 7 commits into from
Sep 4, 2018
Merged

EuiComboBox additions #1139

merged 7 commits into from
Sep 4, 2018

Conversation

cchaos
Copy link
Contributor

@cchaos cchaos commented Aug 23, 2018

When working on #1137, I needed some extra functionality from the EuiComboBox, these are those edits.

1. Allowing onClick to be passed to whole pill

2. Allowing single selection types to show plain text via asPlainText as a property of singleSelection

It also makes sure that single selection types don't grow in height.
screen shot 2018-08-23 at 18 43 22 pm

3. Altering the padding based on props. It used to always be large (2 icon) padding, even if the box wasn't clearable (therefore only had 1 icon).

Before

screen shot 2018-08-23 at 18 44 49 pm

After

screen shot 2018-08-23 at 18 45 09 pm

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Nice! Tested locally and everything works great. I just had a couple suggestions for the code.

@@ -48,7 +48,7 @@ export default class extends Component {
return (
<EuiComboBox
placeholder="Select a single option"
singleSelection={true}
singleSelection={{ asPlainText: true }}
Copy link
Contributor

@cjcenizal cjcenizal Aug 24, 2018

Choose a reason for hiding this comment

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

It seems like this will usually be the desired case, right? I can't think of a situation where we'd want the pill form for single selection. If you agree then how about we update the combo box to use asPlainText: true as default, while still giving people the option to specify false if for some reason they want the pill?

...rest
} = option;

const asPlainText = singleSelection && singleSelection.asPlainText;
Copy link
Contributor

@cjcenizal cjcenizal Aug 24, 2018

Choose a reason for hiding this comment

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

Here's how we can set asPlainText to default to true:

      // Default asPlainText to true if using singleSelection.
      const asPlainText = singleSelection && singleSelection.asPlainText !== false;

Note that this will be a breaking change for anyone who is depending upon the pill form so we'll need to update the CHANGELOG.md.

@@ -31,7 +31,10 @@ export class EuiComboBox extends Component {
placeholder: PropTypes.string,
isLoading: PropTypes.bool,
async: PropTypes.bool,
singleSelection: PropTypes.bool,
singleSelection: PropTypes.oneOfType([
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this propType to also check for the asPlainText property, both here and in combo_box_input.js?

    singleSelection: PropTypes.oneOfType([
      PropTypes.bool,
      PropTypes.shape({
        asPlainText: PropTypes.bool,
      }),
    ]),

@cchaos
Copy link
Contributor Author

cchaos commented Aug 27, 2018

Thanks for taking a look @cjcenizal.

I thought about making it true by default as well, but I really didn't want to have to introduce a breaking change for such a small change. It also still acts a little oddly when just showing in plain text, as the user can keep typing to filter down the list and select a different option. This is odd behavior because by making the selection render plain text, it looks like a normal select, but doesn't act like one. So it's not 100%, and so I wouldn't want to break consumer implementation.

@cjcenizal
Copy link
Contributor

It also still acts a little oddly when just showing in plain text, as the user can keep typing to filter down the list and select a different option

I didn't notice that, good point.

Copy link
Contributor

@cjcenizal cjcenizal 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! Just had one comment about changing a propType.

singleSelection: PropTypes.bool,
singleSelection: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.object,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use PropTypes.shape here too?

@@ -57,13 +61,12 @@ export class EuiComboBoxPill extends Component {
);
}

if (asPlainText) {
return <span className={classes}>{children}</span>;
Copy link
Contributor

Choose a reason for hiding this comment

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

should this also pass ...rest ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Youp, I'll add it. Good catch.

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!

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Loaded in browser and did a code review.

@cchaos
Copy link
Contributor Author

cchaos commented Sep 4, 2018

@chandlerprall
Copy link
Contributor

@cchaos TS change looks good, thanks for making it!

@cchaos
Copy link
Contributor Author

cchaos commented Sep 4, 2018

Sweet! Thx!

@cchaos cchaos merged commit fac1a48 into elastic:master Sep 4, 2018
@cchaos cchaos deleted the combobox-additions branch September 4, 2018 15:44
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.

4 participants