Skip to content

Commit e145a55

Browse files
authored
Merge pull request #390 from cal-smith/master
fix(dropdown): don't focus the button on load
2 parents ea83b1a + e21e5c9 commit e145a55

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/dropdown/dropdown.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ export class Dropdown implements OnInit, AfterContentInit, OnDestroy {
229229
this.propagateChange(this.view.getSelected());
230230
} else {
231231
this.closeMenu();
232-
this.dropdownButton.nativeElement.focus();
233232
if (event.item && event.item.selected) {
234233
if (this.value) {
235234
this.propagateChange(event.item[this.value]);
@@ -487,10 +486,15 @@ export class Dropdown implements OnInit, AfterContentInit, OnDestroy {
487486
* Collapsing the dropdown menu and removing unnecessary `EventListeners`.
488487
*/
489488
closeMenu() {
489+
// return early if the menu is already closed
490+
if (this.menuIsClosed) { return; }
490491
this.menuIsClosed = true;
491492
this.onClose.emit();
492493
this.close.emit();
493494

495+
// focus the trigger button when we close ...
496+
this.dropdownButton.nativeElement.focus();
497+
494498
// remove the conditional once this api is settled and part of abstract-dropdown-view.class
495499
if (this.view["disableScroll"]) {
496500
this.view["disableScroll"]();

0 commit comments

Comments
 (0)