Skip to content

Commit

Permalink
Prevent combobox from complaining about long search values (#3797)
Browse files Browse the repository at this point in the history
* Prevent combobox from complaining about long search values

* changelog
  • Loading branch information
chandlerprall authored Jul 27, 2020
1 parent 915790b commit 1db8ed4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

- Fixed bug in `EuiDataGrid` not calculating the width correctly ([#3789](https://github.com/elastic/eui/pull/3789))

**Bug fixes**

- Fixed `EuiComboBox` marking some very long inputs as invalid ([#3797](https://github.com/elastic/eui/pull/3797))

## [`27.2.0`](https://github.com/elastic/eui/tree/v27.2.0)

- Added `analyzeEvent` glyph in `EuiIcon` ([#3729](https://github.com/elastic/eui/pull/3729))
Expand Down
10 changes: 8 additions & 2 deletions src/components/combo_box/combo_box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,13 @@ export class EuiComboBox<T> extends Component<
});
};

closeList = () => {
closeList = (event?: Event) => {
if (event && event.target === this.searchInputRefInstance) {
// really long search values / custom entries triggers a scroll event on the input
// which the EuiComboBoxOptionsList passes through here
return;
}

this.clearActiveOption();
this.setState({
listZIndex: undefined,
Expand Down Expand Up @@ -674,7 +680,7 @@ export class EuiComboBox<T> extends Component<
}

if (singleSelection) {
requestAnimationFrame(this.closeList);
requestAnimationFrame(() => this.closeList());
} else {
this.setState({
activeOptionIndex: this.state.matchingOptions.indexOf(addedOption),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export type EuiComboBoxOptionsListProps<T> = CommonProps &
isLoading?: boolean;
listRef: RefCallback<HTMLDivElement>;
matchingOptions: Array<EuiComboBoxOptionOption<T>>;
onCloseList: () => void;
onCloseList: (event: Event) => void;
onCreateOption?: (
searchValue: string,
options: Array<EuiComboBoxOptionOption<T>>
Expand Down Expand Up @@ -184,7 +184,7 @@ export class EuiComboBoxOptionsList<T> extends Component<
event.target &&
this.listRefInstance.contains(event.target as Node) === false
) {
this.props.onCloseList();
this.props.onCloseList(event);
}
};

Expand Down

0 comments on commit 1db8ed4

Please sign in to comment.