Skip to content

Commit

Permalink
fix(core): remove OnPush from dialog container
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerodonnell89 committed Oct 7, 2024
1 parent 104e1f5 commit ab150b7
Showing 1 changed file with 4 additions and 32 deletions.
36 changes: 4 additions & 32 deletions libs/core/dialog/dialog-container/dialog-container.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { AnimationEvent } from '@angular/animations';
import {
AfterContentChecked,
AfterViewInit,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ComponentRef,
DestroyRef,
ElementRef,
EmbeddedViewRef,
HostBinding,
HostListener,
Injector,
Expand All @@ -17,13 +13,12 @@ import {
TemplateRef,
Type,
ViewChild,
ViewEncapsulation,
ViewRef
ViewEncapsulation
} from '@angular/core';

import { applyCssClass, CssClassBuilder, DynamicComponentContainer, Nullable } from '@fundamental-ngx/cdk/utils';

import { CdkPortalOutlet, CdkPortalOutletAttachedRef, PortalModule } from '@angular/cdk/portal';
import { CdkPortalOutlet, PortalModule } from '@angular/cdk/portal';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { DialogDefaultComponent } from '../dialog-default/dialog-default.component';
import { DialogContentType } from '../dialog.types';
Expand All @@ -37,17 +32,16 @@ import { dialogFade } from '../utils/dialog.animations';
/** Dialog container where the dialog content is embedded. */
@Component({
selector: 'fd-dialog-container',
template: '<ng-template (attached)="_attached($event)" cdkPortalOutlet></ng-template>',
template: '<ng-template cdkPortalOutlet></ng-template>',
styleUrl: './dialog-container.component.scss',
animations: [dialogFade],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [PortalModule]
})
export class DialogContainerComponent
extends DynamicComponentContainer<DialogContentType>
implements DialogContainer<any>, AfterViewInit, AfterContentChecked, CssClassBuilder
implements DialogContainer<any>, AfterViewInit, CssClassBuilder
{
/** Custom classes */
@Input()
Expand Down Expand Up @@ -78,7 +72,6 @@ export class DialogContainerComponent
public ref: DialogRef,
private _destroyRef: DestroyRef,
elementRef: ElementRef,
protected readonly _cdr: ChangeDetectorRef,
injector: Injector
) {
super(elementRef, injector);
Expand Down Expand Up @@ -109,27 +102,8 @@ export class DialogContainerComponent
});
}

/** @hidden */
ngAfterContentChecked(): void {
if (this.portalOutlet) {
this._cdr.markForCheck();
}
}

/** @hidden */
protected _attached(event: CdkPortalOutletAttachedRef): void {
if (event instanceof ComponentRef) {
event.changeDetectorRef.markForCheck();
} else if (event instanceof EmbeddedViewRef) {
event.markForCheck();
}
}

/** @hidden Load received content */
protected _loadContent(): void {
if ((this._cdr as ViewRef).destroyed) {
return;
}
if (this.childContent instanceof Type) {
this._createFromComponent(this.childContent);
} else if (this.childContent instanceof TemplateRef) {
Expand All @@ -138,7 +112,6 @@ export class DialogContainerComponent
this._createFromDefaultDialog(this.childContent);
}
this._animationStateSignal.set('visible');
this._cdr.detectChanges();
}

/** @hidden Returns context for embedded template*/
Expand All @@ -161,7 +134,6 @@ export class DialogContainerComponent
private _listenOnClose(): void {
const callback: () => void = () => {
this._animationStateSignal.set('hidden');
this._cdr.detectChanges();
};
this.ref.afterClosed.pipe(takeUntilDestroyed(this._destroyRef)).subscribe({
next: () => callback(),
Expand Down

0 comments on commit ab150b7

Please sign in to comment.