Skip to content

Commit

Permalink
Correction a problem with tab navigation and unfocus
Browse files Browse the repository at this point in the history
  • Loading branch information
Zefling committed Aug 3, 2017
1 parent af96ed1 commit 63585df
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export class Select2 implements ControlValueAccessor {
if (this.disabled) {
return;
}
this.focused = true;
this.isOpen = !this.isOpen;
if (this.isOpen) {
this.innerSearchText = "";
Expand All @@ -235,7 +236,6 @@ export class Select2 implements ControlValueAccessor {
this.lastScrollTopIndex = lastScrollTopIndex;
}
}

this.open.emit();
}
if (this.focusoutTimer) {
Expand All @@ -248,12 +248,14 @@ export class Select2 implements ControlValueAccessor {
}

focusout() {
this.focusoutTimer = setTimeout(() => {
this.isOpen = false;
this.focusoutTimer = undefined;
this.focused = false;
this._changeDetectorRef.markForCheck();
}, common.timeout);
if (this.focused && !this.isOpen) {
this.focusoutTimer = setTimeout(() => {
this.isOpen = false;
this.focusoutTimer = undefined;
this.focused = false;
this._changeDetectorRef.markForCheck();
}, common.timeout);
}
}

moveUp() {
Expand Down Expand Up @@ -337,6 +339,9 @@ export class Select2 implements ControlValueAccessor {
} else if (e.keyCode === 13) {
this.selectByEnter();
e.preventDefault();
} else if (e.keyCode === 9) {
this.toggleOpenAndClose();
this.focused = false;
}
}

Expand All @@ -347,7 +352,6 @@ export class Select2 implements ControlValueAccessor {
}
}


searchUpdate(e: Event) {
this.searchText = (<HTMLInputElement>e.target).value;
}
Expand Down

0 comments on commit 63585df

Please sign in to comment.