Skip to content

Commit

Permalink
fix(dialog): stop listening for close events when dialog closes (#1860)
Browse files Browse the repository at this point in the history
  • Loading branch information
yggg authored Jul 29, 2019
1 parent 0542371 commit 7ddbfbd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/framework/theme/components/dialog/dialog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { ComponentFactoryResolver, Inject, Injectable, Injector, TemplateRef, Type } from '@angular/core';
import { fromEvent as observableFromEvent } from 'rxjs';
import { filter } from 'rxjs/operators';
import { filter, takeUntil } from 'rxjs/operators';

import {
NbComponentPortal,
Expand Down Expand Up @@ -242,7 +242,10 @@ export class NbDialogService {

if (config.closeOnEsc) {
observableFromEvent(this.document, 'keyup')
.pipe(filter((event: KeyboardEvent) => event.keyCode === 27))
.pipe(
filter((event: KeyboardEvent) => event.keyCode === 27),
takeUntil(dialogRef.onClose),
)
.subscribe(() => dialogRef.close());
}
}
Expand Down

0 comments on commit 7ddbfbd

Please sign in to comment.