Skip to content

Commit

Permalink
[EuiSelectable] call searchProps functions on search/change (#4153)
Browse files Browse the repository at this point in the history
* calling search props functions on search/change

* adding method property and types per pr feedback
  • Loading branch information
krosenk729 authored Nov 9, 2020
1 parent ace700d commit d99c683
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Fixed a condition in `EuiInMemoryTable` to avoid mistaken assignment of `sortName` ([#4138](https://github.com/elastic/eui/pull/4138))
- Fixed bug in small `EuiImage`'s not respecting the optional sizes when `allowFullScreen` is set to true ([#4207](https://github.com/elastic/eui/pull/4207))
- Fixed incorrect initial rendering of `EuiDualRange` thumbs when element width is 0 ([#4230](https://github.com/elastic/eui/pull/4230))
- Fixed bug in `EuiSelectable` to call `searchProps.onChange` and `searchProps.onSearch` calls in `EuiSelectable` ([#4153](https://github.com/elastic/eui/pull/4153))

**Theme: Amsterdam**

Expand Down
14 changes: 13 additions & 1 deletion src/components/selectable/selectable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ export class EuiSelectable<T = {}> extends Component<
}
}
);
if (this.props.searchProps && this.props.searchProps.onSearch) {
this.props.searchProps.onSearch(searchValue);
}
};

onContainerBlur = (e: React.FocusEvent) => {
Expand All @@ -353,6 +356,12 @@ export class EuiSelectable<T = {}> extends Component<
if (this.props.onChange) {
this.props.onChange(options);
}
if (this.props.searchProps && this.props.searchProps.onChange) {
this.props.searchProps.onChange(
{ ...this.state.visibleOptions },
this.state.searchValue
);
}
};

render() {
Expand Down Expand Up @@ -390,8 +399,11 @@ export class EuiSelectable<T = {}> extends Component<
const {
'aria-label': searchAriaLabel,
'aria-describedby': searchAriaDescribedby,
onChange: propsOnChange,
onSearch,
...cleanedSearchProps
} = searchProps || unknownAccessibleName;
} = (searchProps || unknownAccessibleName) as typeof searchProps &
typeof unknownAccessibleName;
const {
'aria-label': listAriaLabel,
'aria-describedby': listAriaDescribedby,
Expand Down

0 comments on commit d99c683

Please sign in to comment.