From 038ca07453f4c01c3f0f13d676d3c5bf31596890 Mon Sep 17 00:00:00 2001 From: Morgan Touverey Quilling Date: Fri, 31 Jan 2020 14:24:57 +0100 Subject: [PATCH] fix(SwalPortalDirective): fix Angular view not freed when modal is closed by another modal Fixes #147 --- projects/ngx-sweetalert2/src/lib/swal-portal.directive.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/ngx-sweetalert2/src/lib/swal-portal.directive.ts b/projects/ngx-sweetalert2/src/lib/swal-portal.directive.ts index 79f7db9..d4b16a8 100644 --- a/projects/ngx-sweetalert2/src/lib/swal-portal.directive.ts +++ b/projects/ngx-sweetalert2/src/lib/swal-portal.directive.ts @@ -82,7 +82,7 @@ export class SwalPortalDirective implements OnInit, OnDestroy { //=> Subscribe to a few hooks frm the parent SwalComponent. this.swalComponent.render.pipe(takeUntil(this.destroyed)).subscribe(this.renderHook.bind(this)); this.swalComponent.beforeOpen.pipe(takeUntil(this.destroyed)).subscribe(this.beforeOpenHook.bind(this)); - this.swalComponent.afterClose.pipe(takeUntil(this.destroyed)).subscribe(this.afterCloseHook.bind(this)); + this.swalComponent.destroy.pipe(takeUntil(this.destroyed)).subscribe(this.destroyHook.bind(this)); } /** @@ -137,7 +137,7 @@ export class SwalPortalDirective implements OnInit, OnDestroy { * This afterClose hook runs once (per modal instance), just after the modal closing animation terminated. * This is a good place to detach and destroy our content, that is not visible anymore. */ - private afterCloseHook(): void { + private destroyHook(): void { if (!this.portalComponentRef) return; //=> Detach the portal component from the app and destroy it