Skip to content

Commit

Permalink
Fixed #10106 - Dropdown closing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Apr 15, 2021
1 parent 86b1cca commit 3b63bcb
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/app/components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,13 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView
};

set disabled(_disabled: boolean) {
if (_disabled)
if (_disabled) {
this.focused = false;

if (this.overlayVisible)
this.hide();
}

this._disabled = _disabled;
if (!(this.cd as ViewRef).destroyed) {
this.cd.detectChanges();
Expand Down Expand Up @@ -444,7 +448,7 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView
}

setTimeout(() => {
this.hide(event);
this.hide();
}, 150);
}

Expand Down Expand Up @@ -554,7 +558,7 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView
this.accessibleViewChild.nativeElement.focus();

if (this.overlayVisible)
this.hide(event);
this.hide();
else
this.show();

Expand All @@ -577,7 +581,7 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView

onEditableInputFocus(event) {
this.focused = true;
this.hide(event);
this.hide();
this.onFocus.emit(event);
}

Expand Down Expand Up @@ -632,6 +636,7 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView

case 'void':
this.onOverlayHide();
this.onHide.emit(event);
break;
}
}
Expand Down Expand Up @@ -678,7 +683,7 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView
}
}

hide(event) {
hide() {
this.overlayVisible = false;

if (this.filter && this.resetFilterOnHide) {
Expand All @@ -690,7 +695,6 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView
}

this.cd.markForCheck();
this.onHide.emit(event);
}

alignOverlay() {
Expand Down Expand Up @@ -868,7 +872,7 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView
//enter
case 13:
if (!this.filter || (this.optionsToDisplay && this.optionsToDisplay.length > 0)) {
this.hide(event);
this.hide();
}

event.preventDefault();
Expand All @@ -877,7 +881,7 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView
//escape and tab
case 27:
case 9:
this.hide(event);
this.hide();
break;

//search item based on keyboard input
Expand Down Expand Up @@ -1086,7 +1090,7 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView

this.documentClickListener = this.renderer.listen(documentTarget, 'click', (event) => {
if (this.isOutsideClicked(event)) {
this.hide(event);
this.hide();
this.unbindDocumentClickListener();
}

Expand Down Expand Up @@ -1116,15 +1120,15 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView

onWindowResize() {
if (!DomHandler.isAndroid()) {
this.hide(event);
this.hide();
}
}

bindScrollListener() {
if (!this.scrollHandler) {
this.scrollHandler = new ConnectedOverlayScrollHandler(this.containerViewChild.nativeElement, (event: any) => {
if (this.overlayVisible) {
this.hide(event);
this.hide();
}
});
}
Expand Down

0 comments on commit 3b63bcb

Please sign in to comment.