Skip to content

Commit

Permalink
EuiComboBox - remove cross icon when singleSelection is enabled (#769)
Browse files Browse the repository at this point in the history
* EuiComboBox - remove cross icon when singleSelection is enabled

* change log

* more clear change log message
  • Loading branch information
nreese authored May 3, 2018
1 parent bd21c3b commit a398a53
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Added `EuiDescribedFormGroup` component, a wrapper around `EuiFormRow`(s) ([#707](https://github.com/elastic/eui/pull/707))
- Added `describedByIds` prop to `EuiFormRow` to help with accessibility ([#707](https://github.com/elastic/eui/pull/707))
- Added `isLoading` prop to `EuiButtonEmpty` ([#768](https://github.com/elastic/eui/pull/768))
- Removed individual badge cross icon when `EuiComboBox` has `singleSelection` prop enabled. ([#769](https://github.com/elastic/eui/pull/769))

## [`0.0.45`](https://github.com/elastic/eui/tree/v0.0.45)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports[`EuiComboBox is rendered 1`] = `
onRemoveOption={[Function]}
searchValue=""
selectedOptions={Array []}
singleSelection={false}
updatePosition={[Function]}
value=""
/>
Expand Down
4 changes: 3 additions & 1 deletion src/components/combo_box/combo_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class EuiComboBox extends Component {
options: [],
selectedOptions: [],
isClearable: true,
singleSelection: false,
}

constructor(props) {
Expand Down Expand Up @@ -497,7 +498,7 @@ export class EuiComboBox extends Component {
placeholder,
noSuggestions,
renderOption,
singleSelection, // eslint-disable-line no-unused-vars
singleSelection,
onChange, // eslint-disable-line no-unused-vars
onSearchChange, // eslint-disable-line no-unused-vars
async, // eslint-disable-line no-unused-vars
Expand Down Expand Up @@ -572,6 +573,7 @@ export class EuiComboBox extends Component {
isListOpen={isListOpen}
onOpen={this.openList}
onClose={this.closeList}
singleSelection={singleSelection}
/>

{optionsList}
Expand Down
4 changes: 3 additions & 1 deletion src/components/combo_box/combo_box_input/combo_box_input.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class EuiComboBoxInput extends Component {
isListOpen: PropTypes.bool.isRequired,
onOpen: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
singleSelection: PropTypes.bool,
}

constructor(props) {
Expand Down Expand Up @@ -85,6 +86,7 @@ export class EuiComboBoxInput extends Component {
isListOpen,
onOpen,
onClose,
singleSelection,
} = this.props;

const pills = selectedOptions.map((option) => {
Expand All @@ -97,7 +99,7 @@ export class EuiComboBoxInput extends Component {
return (
<EuiComboBoxPill
option={option}
onClose={onRemoveOption}
onClose={singleSelection ? null : onRemoveOption}
key={label.toLowerCase()}
color={color}
{...rest}
Expand Down
27 changes: 20 additions & 7 deletions src/components/combo_box/combo_box_input/combo_box_pill.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class EuiComboBoxPill extends Component {
children: PropTypes.string,
className: PropTypes.string,
color: PropTypes.string,
onClose: PropTypes.func.isRequired,
onClose: PropTypes.func,
};

static defaultProps = {
Expand All @@ -37,17 +37,30 @@ export class EuiComboBoxPill extends Component {
} = this.props;
const classes = classNames('euiComboBoxPill', className);

if (onClose) {
return (
<EuiBadge
className={classes}
title={children}
iconOnClick={this.onCloseButtonClick}
iconType="cross"
iconSide="right"
color={color}
closeButtonProps={{
tabIndex: '-1'
}}
{...rest}
>
{children}
</EuiBadge>
);
}

return (
<EuiBadge
className={classes}
title={children}
iconOnClick={this.onCloseButtonClick}
iconType="cross"
iconSide="right"
color={color}
closeButtonProps={{
tabIndex: '-1'
}}
{...rest}
>
{children}
Expand Down

0 comments on commit a398a53

Please sign in to comment.