Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component: DynamicDialog not working with zonejs less application #16402

Closed
Trolejbus opened this issue Sep 18, 2024 · 5 comments · Fixed by #17123
Closed

Component: DynamicDialog not working with zonejs less application #16402

Trolejbus opened this issue Sep 18, 2024 · 5 comments · Fixed by #17123
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@Trolejbus
Copy link

Trolejbus commented Sep 18, 2024

Describe the bug

I am not sure if PrimeNg lib is adapted to work with zonejs less Angular application (with provideExperimentalZonelessChangeDetection()), but if so than after closing dynamic dialog with overlay mask behind it, dialog is correctly closed, but overlay is not destroyed from html.

Environment

Windows/Chrome 128.0.6613.138

Reproducer

https://stackblitz.com/edit/stackblitz-starters-tpcpxh?file=src%2Fmain.ts

Angular version

18.0.2

PrimeNG version

17.18.10

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

v20.10.0

Browser(s)

Chrome 128.0.6613.138

Steps to reproduce the behavior

  1. Navigate to provided stackblitz
  2. Click "Open dialog" button.
  3. Close dialog.
  4. Click "Open dialog" button again. - it should not be possible since overlay is not allowing to click button.

Uncommenting commented code fixes issue.

Expected behavior

Overlay should be destroyed after closing dialog.

@Trolejbus Trolejbus added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Sep 18, 2024
@juanchavezlive
Copy link

Same error here. Had to remove Zoneless support

@Trolejbus
Copy link
Author

Same error here. Had to remove Zoneless support

Hey, you can check my example. In this particular issue you can trigger change detection manually as a potential workaround for this issue :)

@Bock92
Copy link
Contributor

Bock92 commented Nov 6, 2024

Hi guys, I found another solution about this issue:

Suppose to have a method that called this line of code:
this.dialogService.open<LoaderComponent>(LoaderComponent, { data: {...} });

Inside the LoaderComponent inject the DynamicDialogConfig and implement the OnDestroy interface with the following line of code: this.dynamicDialogRef.destroy();

This will clean and remove from the DOM the dialog in a proper way.

This solution allows you to open a modal directly from an Angular Service, NgRx Signal Store, or other non-component contexts, where ChangeDetectorRef isn't accessible.

@mertsincan mertsincan added Resolution: Help Wanted Issue or pull request requires extra help and feedback and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 19, 2024
Copy link

Due to PrimeNG team's busy roadmap, this issue is available for anyone to work on. Make sure to reference this issue in your pull request. ✨ Thank you for your contribution! ✨

@mertsincan mertsincan added this to the Future milestone Nov 19, 2024
@github-project-automation github-project-automation bot moved this to Review in PrimeNG Dec 11, 2024
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Resolution: Help Wanted Issue or pull request requires extra help and feedback labels Dec 26, 2024
@cetincakiroglu cetincakiroglu modified the milestones: Future, 19.0.2 Dec 26, 2024
@github-project-automation github-project-automation bot moved this from Review to Done in PrimeNG Dec 26, 2024
@ThoSap
Copy link
Contributor

ThoSap commented Dec 30, 2024

@Trolejbus @Bock92 @cetincakiroglu the issue has been present and has been caused since the Angular 18.2.2 release and is unrelated to the mentioned PrimeNG 17.18.10 release.

My zoneless PrimeNG application worked perfectly fine with PrimeNG 17.18.15 until I upgraded from Angular 18.2.0 to 18.2.13.

I thoroughly tracked down the root cause of the bug, and it seems to be a change in the @angular/core@18.2.2 package.
If I upgrade ALL @angular/* dependencies to 18.2.13 and pin @angular/core to 18.2.1, my dynamic dialog properly closes and destroys the overlay mask.

The change that causes this is an afterRender hook change in @angular/core, which is not even mentioned in the Angular 18.2.2 changelog:
angular/angular@800f6c8
angular/angular@6059ca8
angular/angular@b80af11

@alxhub could you please have a quick lock at PR #17123 if this is a proper fix after the Angular 18.2.2 afterRender hook change or is the "workaround" #16402 (comment) the proper way to clean things up?

After this change even some Angular tests and the angular.dev website had to add an additional ref destroy call, the same as we did with the workaround in #16402 (comment), see:
angular/angular@df42d2b
angular/angular@5e9661d

Related PRs:
angular/angular#57453
angular/angular#57504
angular/angular#57546
angular/angular#57552
angular/angular#57554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants