Skip to content

Commit 701ecd2

Browse files
committed
fix(dropdown): visible dropdown keyup event closes parent modal
1 parent 5114dc0 commit 701ecd2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

projects/coreui-angular/src/lib/dropdown/dropdown/dropdown.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,11 @@ export class DropdownComponent implements AfterContentInit, OnDestroy, OnInit {
398398
})
399399
);
400400
this.listeners.push(
401-
this.renderer.listen(this.document, 'keyup', (event) => {
401+
this.renderer.listen(this.elementRef.nativeElement, 'keyup', (event) => {
402402
if (event.key === 'Escape' && this.autoClose !== false) {
403+
event.stopPropagation();
403404
this.setVisibleState(false);
405+
return;
404406
}
405407
})
406408
);

projects/coreui-angular/src/lib/modal/modal/modal.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export class ModalComponent implements OnInit, OnDestroy {
217217
this.show = this.visible;
218218
}
219219

220-
@HostListener('document:keydown', ['$event'])
220+
@HostListener('document:keyup', ['$event'])
221221
onKeyDownHandler(event: KeyboardEvent): void {
222222
if (event.key === 'Escape' && this.keyboard && this.visible) {
223223
if (this.backdrop === 'static') {

0 commit comments

Comments
 (0)