Skip to content

Commit 1df1242

Browse files
committed
fix(combobox): the whole input should trigger the dropdown
1 parent 24bc4de commit 1df1242

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/combobox/combobox.component.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import { NG_VALUE_ACCESSOR } from "@angular/forms";
3737
tabindex="0"
3838
type="button"
3939
aria-label="close menu"
40-
aria-haspopup="true">
40+
aria-haspopup="true"
41+
(click)="toggleDropdown()">
4142
<div
4243
*ngIf="type === 'multi' && pills.length > 0"
4344
(click)="clearSelected()"
@@ -60,7 +61,6 @@ import { NG_VALUE_ACCESSOR } from "@angular/forms";
6061
</div>
6162
<input
6263
[disabled]="disabled"
63-
(click)="toggleDropdown()"
6464
(keyup)="onSearch($event.target.value)"
6565
[value]="selectedValue"
6666
class="bx--text-input"
@@ -248,7 +248,7 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
248248
this.selectedValue = "";
249249
this.propagateChangeCallback(null);
250250
}
251-
// not gaurding these since the nativeElement has to be loaded
251+
// not guarding these since the nativeElement has to be loaded
252252
// for select to even fire
253253
this.elementRef.nativeElement.querySelector("input").focus();
254254
this.closeDropdown();
@@ -286,12 +286,15 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
286286
hostkeys(ev: KeyboardEvent) {
287287
if (ev.key === "Escape") {
288288
this.closeDropdown();
289-
} else if (ev.key === "ArrowDown" && !this.dropdownMenu.nativeElement.contains(ev.target)) {
289+
} else if (ev.key === "ArrowDown"
290+
&& (!this.dropdownMenu || !this.dropdownMenu.nativeElement.contains(ev.target))) {
290291
ev.stopPropagation();
291292
this.openDropdown();
292293
setTimeout(() => this.view.getCurrentElement().focus(), 0);
293-
} else if (ev.key === "ArrowUp" && this.dropdownMenu.nativeElement.contains(ev.target) && !this.view["hasPrevElement"]()) {
294-
this.elementRef.nativeElement.querySelector(".combobox_input").focus();
294+
} else if (ev.key === "ArrowUp"
295+
&& this.dropdownMenu.nativeElement.contains(ev.target)
296+
&& !this.view["hasPrevElement"]()) {
297+
this.elementRef.nativeElement.querySelector(".bx--text-input").focus();
295298
}
296299
}
297300

@@ -349,7 +352,6 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
349352

350353
/**
351354
* Closes the dropdown and emits the close event.
352-
* @memberof ComboBox
353355
*/
354356
public closeDropdown() {
355357
this.open = false;
@@ -358,15 +360,13 @@ export class ComboBox implements OnChanges, OnInit, AfterViewInit, AfterContentI
358360

359361
/**
360362
* Opens the dropdown.
361-
* @memberof ComboBox
362363
*/
363364
public openDropdown() {
364365
this.open = true;
365366
}
366367

367368
/**
368369
* Toggles the dropdown.
369-
* @memberof ComboBox
370370
*/
371371
public toggleDropdown() {
372372
if (this.open) {

0 commit comments

Comments
 (0)