Skip to content

Commit 6c7bfae

Browse files
committed
fix(collapse): NG0953: Unexpected emit for destroyed OutputRef. The owning directive/component is destroyed.
1 parent 310cebe commit 6c7bfae

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

projects/coreui-angular/src/lib/collapse/collapse.directive.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import {
2929
host: { '[class]': 'hostClasses()', '[style]': '{ display: "none" }' }
3030
})
3131
export class CollapseDirective implements OnDestroy {
32+
readonly #animationBuilder = inject(AnimationBuilder);
3233
readonly #hostElement = inject(ElementRef);
3334
readonly #renderer = inject(Renderer2);
34-
readonly #animationBuilder = inject(AnimationBuilder);
3535
#player: AnimationPlayer | undefined = undefined;
3636

3737
constructor() {
@@ -158,7 +158,9 @@ export class CollapseDirective implements OnDestroy {
158158
this.#renderer.addClass(host, 'collapsing');
159159
this.#renderer.removeClass(host, 'show');
160160
this.#renderer.setStyle(host, dimension, visible ? `${(host as any)[scrollSize]}px` : '');
161-
this.collapseChange?.emit(visible ? 'opening' : 'collapsing');
161+
if (this.#player) {
162+
this.collapseChange?.emit(visible ? 'opening' : 'collapsing');
163+
}
162164
});
163165

164166
this.#player.onDone(() => {
@@ -170,9 +172,11 @@ export class CollapseDirective implements OnDestroy {
170172
} else {
171173
this.#renderer.removeClass(host, 'show');
172174
}
173-
this.collapseChange?.emit(visible ? 'open' : 'collapsed');
175+
if (this.#player) {
176+
this.collapseChange?.emit(visible ? 'open' : 'collapsed');
177+
this.visibleChange?.emit(visible);
178+
}
174179
this.destroyPlayer();
175-
this.visibleChange.emit(visible);
176180
});
177181

178182
this.#player?.play();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy