Skip to content

Commit

Permalink
Prevent refocusing EuiComboBox input after container blur event (#1863)
Browse files Browse the repository at this point in the history
* prevent refocusing input after container blur event

* formatting

* #1863 CL
  • Loading branch information
thompsongl authored Apr 19, 2019
1 parent b2a5487 commit 98ffbed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
**Bug fixes**

- Added `toastLifeTimeMs` typescript definition for individual toasts in `EuiGlobalToastList` ([#1846](https://github.com/elastic/eui/pull/1846))
- Added logic to prevent refocusing `EuiComboBox` input after container blur event ([#1863](https://github.com/elastic/eui/pull/1863))

## [`10.0.1`](https://github.com/elastic/eui/tree/v10.0.1)

Expand Down
12 changes: 7 additions & 5 deletions src/components/combo_box/combo_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class EuiComboBox extends Component {
this.onRemoveOption(this.props.selectedOptions[this.props.selectedOptions.length - 1]);
};

addCustomOption = () => {
addCustomOption = (isContainerBlur) => {
const {
options,
selectedOptions,
Expand All @@ -226,7 +226,7 @@ export class EuiComboBox extends Component {
} = this.state;

if (this.doesSearchMatchOnlyOption()) {
this.onAddOption(matchingOptions[0]);
this.onAddOption(matchingOptions[0], isContainerBlur);
return;
}

Expand Down Expand Up @@ -294,7 +294,7 @@ export class EuiComboBox extends Component {
// If the user tabs away or changes focus to another element, take whatever input they've
// typed and convert it into a pill, to prevent the combo box from looking like a text input.
if (!this.hasActiveOption()) {
this.addCustomOption();
this.addCustomOption(true);
}
}
}
Expand Down Expand Up @@ -367,7 +367,7 @@ export class EuiComboBox extends Component {
this.onAddOption(option);
}

onAddOption = (addedOption) => {
onAddOption = (addedOption, isContainerBlur) => {
if (addedOption.disabled) {
return;
}
Expand All @@ -384,7 +384,9 @@ export class EuiComboBox extends Component {
}

this.clearActiveOption();
this.searchInput.focus();
if (!isContainerBlur) {
this.searchInput.focus();
}
};

onRemoveOption = (removedOption) => {
Expand Down

0 comments on commit 98ffbed

Please sign in to comment.