Skip to content

Commit

Permalink
1430: fix combobox item selection in IE11 (#1437)
Browse files Browse the repository at this point in the history
* 1430: fix combobox item selection in IE11

* changelog
  • Loading branch information
chandlerprall authored Jan 16, 2019
1 parent 5cf5473 commit 99875ca
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
- Added `inputRef` prop to `EuiComboBox` ([#1433](https://github.com/elastic/eui/pull/1433))
- Added custom date string formatting for series charts crosshair overlay ([#1429](https://github.com/elastic/eui/pull/1429))

**Bug fixes**

- Fix mouse interaction with `EuiComboBox` in IE11 ([#1437](https://github.com/elastic/eui/pull/1437))

## [`6.3.1`](https://github.com/elastic/eui/tree/v6.3.1)

**Bug fixes**
Expand Down
7 changes: 0 additions & 7 deletions src/components/combo_box/__snapshots__/combo_box.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ exports[`props full width is rendered 1`] = `
aria-expanded={false}
aria-haspopup="listbox"
className="euiComboBox euiComboBox--fullWidth"
onBlur={[Function]}
onKeyDown={[Function]}
role="combobox"
>
Expand Down Expand Up @@ -119,7 +118,6 @@ exports[`props isClearable=false disallows user from clearing input when no opti
aria-expanded={false}
aria-haspopup="listbox"
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
role="combobox"
>
Expand Down Expand Up @@ -155,7 +153,6 @@ exports[`props isClearable=false disallows user from clearing input when options
aria-expanded={false}
aria-haspopup="listbox"
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
role="combobox"
>
Expand Down Expand Up @@ -200,7 +197,6 @@ exports[`props isDisabled is rendered 1`] = `
aria-expanded={false}
aria-haspopup="listbox"
className="euiComboBox euiComboBox-isDisabled"
onBlur={[Function]}
onKeyDown={[Function]}
role="combobox"
>
Expand Down Expand Up @@ -332,7 +328,6 @@ exports[`props selectedOptions are rendered 1`] = `
aria-expanded={false}
aria-haspopup="listbox"
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
role="combobox"
>
Expand Down Expand Up @@ -378,7 +373,6 @@ exports[`props singleSelection is rendered 1`] = `
aria-expanded={false}
aria-haspopup="listbox"
className="euiComboBox"
onBlur={[Function]}
onKeyDown={[Function]}
role="combobox"
>
Expand Down Expand Up @@ -421,7 +415,6 @@ exports[`props singleSelection selects existing option when opened 1`] = `
aria-expanded={true}
aria-haspopup="listbox"
className="euiComboBox euiComboBox-isOpen"
onBlur={[Function]}
onKeyDown={[Function]}
role="combobox"
>
Expand Down
15 changes: 8 additions & 7 deletions src/components/combo_box/combo_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,6 @@ export class EuiComboBox extends Component {
}
}

onComboBoxLoseFocus = e => {
if (!this.comboBox || !this.comboBox.contains(e.relatedTarget)) {
this.closeList();
}
}

onKeyDown = (e) => {
switch (e.keyCode) {
case comboBoxKeyCodes.UP:
Expand Down Expand Up @@ -434,8 +428,16 @@ export class EuiComboBox extends Component {
};

comboBoxRef = node => {
// IE11 doesn't support the `relatedTarget` event property for blur events
// but does add it for focusout. React doesn't support `onFocusOut` so here we are.
if (this.comboBox != null) {
this.comboBox.removeEventListener('focusout', this.onContainerBlur);
}

this.comboBox = node;

if (this.comboBox) {
this.comboBox.addEventListener('focusout', this.onContainerBlur);
const comboBoxBounds = this.comboBox.getBoundingClientRect();
this.setState({
width: comboBoxBounds.width,
Expand Down Expand Up @@ -626,7 +628,6 @@ export class EuiComboBox extends Component {
onKeyDown={this.onKeyDown}
ref={this.comboBoxRef}
data-test-subj={dataTestSubj}
onBlur={this.onContainerBlur}
role="combobox"
aria-haspopup="listbox"
aria-expanded={isListOpen}
Expand Down
6 changes: 5 additions & 1 deletion src/components/combo_box/combo_box.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ describe('behavior', () => {
component.setState({ searchValue: 'foo' });
const searchInput = findTestSubject(component, 'comboBoxSearchInput');
searchInput.simulate('focus');
searchInput.simulate('blur');

const searchInputNode = searchInput.getDOMNode();
// React doesn't support `focusout` so we have to manually trigger it
searchInputNode.dispatchEvent(new FocusEvent('focusout', { bubbles: true }));

sinon.assert.calledOnce(onCreateOptionHandler);
sinon.assert.calledWith(onCreateOptionHandler, 'foo');
});
Expand Down

0 comments on commit 99875ca

Please sign in to comment.