From e3ff7a9056357786c4c3780f40363f98dfb84a0f Mon Sep 17 00:00:00 2001 From: krosenk729 Date: Sat, 17 Oct 2020 21:32:32 -0400 Subject: [PATCH 1/2] calling search props functions on search/change --- src/components/selectable/selectable.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/selectable/selectable.tsx b/src/components/selectable/selectable.tsx index be5b7b6a999..43e170e30bf 100644 --- a/src/components/selectable/selectable.tsx +++ b/src/components/selectable/selectable.tsx @@ -333,6 +333,9 @@ export class EuiSelectable extends Component< } } ); + if (this.props.searchProps && this.props.searchProps.onSearch) { + this.props.searchProps.onSearch(searchValue); + } }; onContainerBlur = (e: React.FocusEvent) => { @@ -353,6 +356,12 @@ export class EuiSelectable 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() { @@ -390,8 +399,11 @@ export class EuiSelectable extends Component< const { 'aria-label': searchAriaLabel, 'aria-describedby': searchAriaDescribedby, + onChange: propsOnChange, ...cleanedSearchProps - } = searchProps || unknownAccessibleName; + } = + searchProps || + (unknownAccessibleName as Partial>); const { 'aria-label': listAriaLabel, 'aria-describedby': listAriaDescribedby, From 4165eaae9b0f90ecfa0414fc1fa4c4b67f51c3e5 Mon Sep 17 00:00:00 2001 From: krosenk729 Date: Sat, 7 Nov 2020 11:40:12 -0500 Subject: [PATCH 2/2] adding method property and types per pr feedback --- CHANGELOG.md | 1 + src/components/selectable/selectable.tsx | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee9bb243464..006ccc30e0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,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** diff --git a/src/components/selectable/selectable.tsx b/src/components/selectable/selectable.tsx index 43e170e30bf..f3363694cba 100644 --- a/src/components/selectable/selectable.tsx +++ b/src/components/selectable/selectable.tsx @@ -400,10 +400,10 @@ export class EuiSelectable extends Component< 'aria-label': searchAriaLabel, 'aria-describedby': searchAriaDescribedby, onChange: propsOnChange, + onSearch, ...cleanedSearchProps - } = - searchProps || - (unknownAccessibleName as Partial>); + } = (searchProps || unknownAccessibleName) as typeof searchProps & + typeof unknownAccessibleName; const { 'aria-label': listAriaLabel, 'aria-describedby': listAriaDescribedby,