From 40a013be5dc3d6c3b3a973e4922ef09af603ef87 Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Mon, 1 Jun 2020 14:51:15 -0600 Subject: [PATCH 1/2] Fix bug in EuiComboBox's inputRef callback --- src/components/combo_box/combo_box.test.tsx | 15 +++++++++++++++ src/components/combo_box/combo_box.tsx | 1 + 2 files changed, 16 insertions(+) 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; From 3de3c65926b0d2677565f4324a07558734873596 Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Mon, 1 Jun 2020 14:56:00 -0600 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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**