Skip to content

Commit

Permalink
Minor polish to combo box.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed May 24, 2018
1 parent f4fe254 commit 8fecab5
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/components/combo_box/combo_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,16 @@ export class EuiComboBox extends Component {

onFocus = () => {
this.openList();

document.addEventListener('click', this.onDocumentFocusChange);
document.addEventListener('focusin', this.onDocumentFocusChange);
}

onBlur = () => {
this.closeList();

document.removeEventListener('click', this.onDocumentFocusChange);
document.removeEventListener('focusin', this.onDocumentFocusChange);
}

onDocumentFocusChange = event => {
Expand Down Expand Up @@ -366,16 +372,10 @@ export class EuiComboBox extends Component {
break;

case TAB:
if (e.shiftKey) {
if (this.tabAway(-1)) {
e.preventDefault();
e.stopPropagation();
}
} else {
if (this.tabAway(1)) {
e.preventDefault();
e.stopPropagation();
}
const amount = e.shiftKey ? -1 : 1;
if (this.tabAway(amount)) {
e.preventDefault();
e.stopPropagation();
}
break;
}
Expand Down Expand Up @@ -484,8 +484,6 @@ export class EuiComboBox extends Component {

componentDidMount() {
this._isMounted = true;
document.addEventListener('click', this.onDocumentFocusChange);
document.addEventListener('focusin', this.onDocumentFocusChange);

// TODO: This will need to be called once the actual stylesheet loads.
setTimeout(() => {
Expand Down

0 comments on commit 8fecab5

Please sign in to comment.