Skip to content

Commit 5878c2f

Browse files
committed
fix(combobox): use blur event to focus input
1 parent 16d39af commit 5878c2f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/combobox/combobox.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { AbstractDropdownView } from "./../dropdown/abstract-dropdown-view.class";
1717
import { ListItem } from "./../dropdown/list-item.interface";
1818
import { NG_VALUE_ACCESSOR } from "@angular/forms";
19+
import { filter } from "rxjs/operators";
1920

2021
/**
2122
* ComboBoxes are similar to dropdowns, except a combobox provides an input field for users to search items and (optionally) add their own.
@@ -262,6 +263,10 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
262263
setTimeout(() => {
263264
this.updateSelected();
264265
});
266+
267+
this.view.blur.pipe(filter(v => v === "top")).subscribe(() => {
268+
this.elementRef.nativeElement.querySelector(".bx--text-input").focus();
269+
});
265270
}
266271
}
267272

@@ -294,7 +299,7 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
294299
} else if ((ev.key === "ArrowUp" || ev.key === "Up") // `"Up"` is IE specific value
295300
&& this.dropdownMenu.nativeElement.contains(ev.target)
296301
&& !this.view.hasPrevElement()) {
297-
this.elementRef.nativeElement.querySelector(".bx--text-input").focus();
302+
// this.elementRef.nativeElement.querySelector(".bx--text-input").focus();
298303
}
299304
}
300305

0 commit comments

Comments
 (0)