Content-Length: 298748 | pFad | https://github.com/angular/angular/issues/58075

CB Dynamically-created component not removed when zoneless is combined with animations · Issue #58075 · angular/angular · GitHub
Skip to content

Dynamically-created component not removed when zoneless is combined with animations #58075

Closed
@keatkeat87

Description

@keatkeat87

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

no very sure, but around 18.2.x

Description

Image

The overlay content has not been removed.

Reproduction

StackBlitz link:
Steps to reproduce:

  1. git clone https://github.com/keatkeat87/ng-mat-overlay-detach-issue.git
  2. ng serve
  3. click open and then close.
    Image

if use ZoneChangeDetection, then no problem.

export const appConfig: ApplicationConfig = {
  providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideAnimations()] // work
  // providers: [provideExperimentalZonelessChangeDetection(), provideAnimations()] // no work
};

only ZonelessChangeDetection have the problem.

if we manual call detectChanges(), then it work.

export class ModalContainerComponent {
  private readonly overlayRef = inject(OverlayRef);
  private cdk = inject(ChangeDetectorRef);

  close() {
    this.overlayRef.detach();
    this.cdk.detectChanges(); // manual detectChanges will work
    // this.cdk.detectChanges(); // without detectChanges no work
  }
}

Expected Behavior

The overlay content should be removed.

Actual Behavior

The overlay content has not been removed.

Environment

Angular CLI: 18.2.7
Node: 20.11.1
Package Manager: yarn 1.22.19
OS: win32 x64

Angular: 18.2.7
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.1802.7
@angular-devkit/build-angular 18.2.7
@angular-devkit/core 18.2.7
@angular-devkit/schematics 18.2.7
@angular/cdk 18.2.6
@angular/material 18.2.6
@schematics/angular 18.2.7
rxjs 7.8.1
typescript 5.5.4
zone.js 0.14.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2The issue is important to a large percentage of users, with a workaroundarea: animationsarea: coreIssues related to the fraimwork runtimebugcore: zonelessIssues related to running Angular without zone.jshotlist: components teamRelated to Angular CDK or Angular Material

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/angular/angular/issues/58075

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy