diff --git a/CHANGELOG.md b/CHANGELOG.md index d3247b355cd..5d49b12d81c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Fixed `EuiBasicTable` shows no items if all items of last page is deleted ([#3422](https://github.com/elastic/eui/pull/3422)) - Fixed TypeScript module name in generated `eui_charts_theme.d.ts` file ([#3492](https://github.com/elastic/eui/pull/3492)) - Fixed code highlight color contrast in `EuiCodeBlock` ([#3309](https://github.com/elastic/eui/pull/3309)) +- Fixed regression in `EuiComboBox` not triggering its `inputRef` callback ([#3532](https://github.com/elastic/eui/pull/3532)) **Deprecations** diff --git a/src/components/combo_box/combo_box.test.tsx b/src/components/combo_box/combo_box.test.tsx index 7a7c32ffa08..c61907cd70c 100644 --- a/src/components/combo_box/combo_box.test.tsx +++ b/src/components/combo_box/combo_box.test.tsx @@ -372,4 +372,19 @@ describe('behavior', () => { expect(component.state('matchingOptions')[0].label).toBe('Enceladus'); }); }); + + it('calls the inputRef prop with the input element', () => { + const inputRefCallback = jest.fn(); + + const component = mount< + EuiComboBox, + EuiComboBoxProps, + { matchingOptions: TitanOption[] } + >(); + + expect(inputRefCallback).toHaveBeenCalledTimes(1); + expect(component.find('input[role="textbox"]').getDOMNode()).toBe( + inputRefCallback.mock.calls[0][0] + ); + }); }); diff --git a/src/components/combo_box/combo_box.tsx b/src/components/combo_box/combo_box.tsx index 96966b8698a..9f8dc0197ee 100644 --- a/src/components/combo_box/combo_box.tsx +++ b/src/components/combo_box/combo_box.tsx @@ -257,6 +257,7 @@ export class EuiComboBox extends Component< searchInputRefInstance: RefInstance = null; searchInputRefCallback: RefCallback = ref => { this.searchInputRefInstance = ref; + if (this.props.inputRef) this.props.inputRef(ref); }; listRefInstance: RefInstance = null;