Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit f8f8453

Browse files
authored
fix(dialog): Unsubscribe from interactionEventSubscription (#1559)
1 parent 88652ba commit f8f8453

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

packages/dialog/dialog.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,18 @@ import {
88
ElementRef,
99
NgZone,
1010
OnDestroy,
11-
OnInit,
1211
QueryList,
13-
ViewChild,
1412
ViewEncapsulation
1513
} from '@angular/core';
1614
import { merge, Observable, fromEvent, Subject, Subscription } from 'rxjs';
1715
import { takeUntil } from 'rxjs/operators';
1816

19-
import { Platform, toBoolean, ESCAPE } from '@angular-mdc/web/common';
17+
import { Platform } from '@angular-mdc/web/common';
2018

2119
import {
2220
MdcDialogButton,
2321
MdcDialogContent,
24-
MdcDialogSurface,
25-
MdcDialogScrim
22+
MdcDialogSurface
2623
} from './dialog-directives';
2724
import { MdcDialogRef } from './dialog-ref';
2825
import { MdcDialogConfig } from './dialog-config';
@@ -34,7 +31,7 @@ import {
3431
isScrollable,
3532
areTopsMisaligned
3633
} from '@material/dialog/util';
37-
import { strings, numbers } from '@material/dialog/constants';
34+
import { strings } from '@material/dialog/constants';
3835
import { closest, matches } from '@material/dom/ponyfill';
3936
import { MDCDialogFoundation } from '@material/dialog/index';
4037

@@ -193,6 +190,9 @@ export class MdcDialogComponent implements AfterViewInit, OnDestroy {
193190
if (this._layoutEventSubscription) {
194191
this._layoutEventSubscription.unsubscribe();
195192
}
193+
if (this._interactionEventSubscription) {
194+
this._interactionEventSubscription.unsubscribe();
195+
}
196196

197197
if (this._foundation) {
198198
this._foundation.destroy();

test/dialog/dialog.test.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@ import { NgModule, Directive, Component, DebugElement, Injector, TemplateRef, Vi
22
import { inject, ComponentFixture, fakeAsync, TestBed, flush, tick, flushMicrotasks } from '@angular/core/testing';
33
import { Location } from '@angular/common';
44
import { SpyLocation } from '@angular/common/testing';
5-
import { By } from '@angular/platform-browser';
6-
import { Subject } from 'rxjs';
75

86
import { dispatchKeyboardEvent, dispatchFakeEvent } from '../testing/dispatch-events';
97

108
import {
119
ESCAPE,
1210
DOWN_ARROW,
1311
MdcDialog,
14-
MdcDialogButton,
1512
MdcDialogModule,
16-
MdcDialogComponent,
17-
MdcDialogPortal,
18-
MDC_DIALOG_DATA,
1913
MdcDialogRef,
2014
OverlayContainer
2115
} from '@angular-mdc/web';
@@ -24,7 +18,6 @@ describe('MdcDialog Service', () => {
2418
let dialog: MdcDialog;
2519
let overlayContainer: OverlayContainer;
2620
let overlayContainerElement: HTMLElement;
27-
let scrolledSubject = new Subject();
2821

2922
let testViewContainerRef: ViewContainerRef;
3023
let viewContainerFixture: ComponentFixture<ComponentWithChildViewContainer>;
@@ -59,7 +52,7 @@ describe('MdcDialog Service', () => {
5952
});
6053

6154
it('should open a dialog with a component', () => {
62-
let dialogRef = dialog.open(SimpleDialog, {
55+
const dialogRef = dialog.open(SimpleDialog, {
6356
viewContainerRef: testViewContainerRef
6457
});
6558

@@ -80,7 +73,7 @@ describe('MdcDialog Service', () => {
8073

8174
const data = { value: 'Knees' };
8275

83-
let dialogRef = dialog.open(templateRefFixture.componentInstance.templateRef, { data });
76+
const dialogRef = dialog.open(templateRefFixture.componentInstance.templateRef, { data });
8477

8578
viewContainerFixture.detectChanges();
8679

@@ -93,7 +86,7 @@ describe('MdcDialog Service', () => {
9386
});
9487

9588
it('#should open a simple dialog', fakeAsync(() => {
96-
let dialogRef = dialog.open(SimpleDialog);
89+
const dialogRef = dialog.open(SimpleDialog);
9790
expect(dialogRef.componentInstance.dialogRef).toBe(dialogRef);
9891
viewContainerFixture.detectChanges();
9992
flush();
@@ -105,7 +98,7 @@ describe('MdcDialog Service', () => {
10598
}));
10699

107100
it('#should close using escape key', fakeAsync(() => {
108-
let dialogRef = dialog.open(SimpleDialog);
101+
const dialogRef = dialog.open(SimpleDialog);
109102
viewContainerFixture.detectChanges();
110103
flush();
111104

@@ -115,7 +108,7 @@ describe('MdcDialog Service', () => {
115108
}));
116109

117110
it('#should open a simple dialog with options', fakeAsync(() => {
118-
let dialogRef = dialog.open(SimpleDialog, {
111+
const dialogRef = dialog.open(SimpleDialog, {
119112
clickOutsideToClose: false,
120113
escapeToClose: false,
121114
buttonsStacked: false

0 commit comments

Comments
 (0)