Skip to content

Commit

Permalink
Fix bug in EuiComboBox's inputRef callback (elastic#3532)
Browse files Browse the repository at this point in the history
* Fix bug in EuiComboBox's inputRef callback

* changelog
  • Loading branch information
chandlerprall authored and daveyholler committed Jun 3, 2020
1 parent f4f4b44 commit c476985
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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**

Expand Down
15 changes: 15 additions & 0 deletions src/components/combo_box/combo_box.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<TitanOption>,
EuiComboBoxProps<TitanOption>,
{ matchingOptions: TitanOption[] }
>(<EuiComboBox options={options} inputRef={inputRefCallback} />);

expect(inputRefCallback).toHaveBeenCalledTimes(1);
expect(component.find('input[role="textbox"]').getDOMNode()).toBe(
inputRefCallback.mock.calls[0][0]
);
});
});
1 change: 1 addition & 0 deletions src/components/combo_box/combo_box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export class EuiComboBox<T> extends Component<
searchInputRefInstance: RefInstance<HTMLInputElement> = null;
searchInputRefCallback: RefCallback<HTMLInputElement> = ref => {
this.searchInputRefInstance = ref;
if (this.props.inputRef) this.props.inputRef(ref);
};

listRefInstance: RefInstance<HTMLDivElement> = null;
Expand Down

0 comments on commit c476985

Please sign in to comment.