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

DynamicDialog: ExpressionChangedAfterItHasBeenCheckedError for attr.aria-labelledby #13497

Closed
yarikwest opened this issue Aug 14, 2023 · 16 comments · Fixed by #13502 or #13538
Closed

DynamicDialog: ExpressionChangedAfterItHasBeenCheckedError for attr.aria-labelledby #13497

yarikwest opened this issue Aug 14, 2023 · 16 comments · Fixed by #13502 or #13538
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@yarikwest
Copy link

Describe the bug

ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value for 'attr.aria-labelledby': 'pn_id_157_header'. Current value: 'pn_id_159_header'. Expression location: DynamicDialogComponent component.

aria-labeledby is assign for div with class 'p-dynamic-dialog'

Environment

Basic as possible, Angular + PrimeNG only

Reproducer

https://stackblitz.com/edit/pfqjsp?file=package.json

Angular version

16.2.0

PrimeNG version

16.2.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.16.0

Browser(s)

Firefox 116.0

Steps to reproduce the behavior

  1. Open dynamic dialog

Expected behavior

No response

@yarikwest yarikwest added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Aug 14, 2023
@VolodymyrKornetskyi
Copy link

The same issue

@johanrg
Copy link

johanrg commented Aug 14, 2023

Same issue here too.

@chillapp
Copy link

The same issue

@SoyDiego
Copy link
Contributor

I was checking the problem and try using changeDetectorRef, but I still have't been able to fix the error.
I will continue trying 👍🏾

@fbobbio
Copy link
Contributor

fbobbio commented Aug 15, 2023

Same issue here.

@SoyDiego I've just seen this bug. I left this comment on the MR that (I believe) introduced the issue: #13477 (comment)

Is there a need to update the template as per the function change? From the top of my head, the solution would be to bind the template to a property and set it when really needed.

Thanks for the efforts crew.

@SoyDiego
Copy link
Contributor

SoyDiego commented Aug 15, 2023

Hi guys and thanks for your help @fbobbio.
I did a PR solving the problem. You can check here: #13502
I don't know if it's the best solution, but If you find another better, let me know.
I have checked and the problem is solved it and all the things continue working well too
Now we should wait if PrimeNG Team approve it.

@tysoc1222
Copy link

tysoc1222 commented Aug 16, 2023

Same issue here. In my case, the error continuously fires when trying to open the dialog and hence the dialog never opens and the application hangs

@sergeiglikstein
Copy link

sergeiglikstein commented Aug 17, 2023

My work around, example code that I am working on.
I'll stop using it once the issue is fixed.

import { Injectable } from '@angular/core';
import { DialogService, DynamicDialogComponent } from 'primeng/dynamicdialog';
import { ConfirmDialogComponent } from '../../components/confirm-dialog/confirm-dialog.component';
import { ConfirmDialog } from '../../models/confirm-dialog.model';


@Injectable({
  providedIn: 'root'
})
export class SharedDialogService {
  constructor(public dialogService: DialogService) {}

  openConfirmDialog(data: ConfirmDialog, width?: string) {
    const ref = this.dialogService.open(ConfirmDialogComponent, {
      header: data.title,
      data,
      width: width || '600px',
      dismissableMask: false,
      modal: true
    });

    const dialogRef = this.dialogService.dialogComponentRefMap.get(ref);
    const dynamicComponent = dialogRef?.instance as DynamicDialogComponent;

    const ariaLabelledBy = dynamicComponent.getAriaLabelledBy();
    dynamicComponent.getAriaLabelledBy = () => ariaLabelledBy;
    return ref;
  }
}

@kwood-gmr
Copy link

@sergeiglikstein

My work around, example code that I am working on. I'll stop using it once the issue is fixed.

Thank you - this has worked for me

@gucal gucal added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Aug 18, 2023
@gucal gucal added this to the 16.2.1 milestone Aug 18, 2023
@gucal
Copy link
Member

gucal commented Aug 18, 2023

@SoyDiego sent a PR that resolved the issue.
Thanks for report.

@fbobbio
Copy link
Contributor

fbobbio commented Aug 18, 2023

@SoyDiego sent a PR that resolved the issue. Thanks for report.

@gucal and @SoyDiego thanks!
I think the actions failed due to missing prettier: https://github.com/primefaces/primeng/actions/runs/5901308653

Sent this PR #13511

First time contributing here so I am not sure about the workflow to get a new version/tag published :) Would be good to have this fix available.

Thanks again ✌️

@mountpoint
Copy link

in which release will this bug be fixed?

@SoyDiego
Copy link
Contributor

in which release will this bug be fixed?

Wil be in 16.2.1

image

SoyDiego added a commit to SoyDiego/primeng that referenced this issue Aug 23, 2023
gucal added a commit that referenced this issue Aug 24, 2023
Refactor dynamic dialog: Errors when is opened #13497
@gucal
Copy link
Member

gucal commented Aug 24, 2023

The current solution has been replaced with a better solution. #13538

@gucal gucal linked a pull request Aug 24, 2023 that will close this issue
@Tilesto
Copy link

Tilesto commented Aug 27, 2023

Just in case) The same error for 16.2.0. Looking forward to 16.2.1)

@SoyDiego
Copy link
Contributor

Just in case) The same error for 16.2.0. Looking forward to 16.2.1)

Yes, will be fixed in next release and the currently 16.2.0 has the problem

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
None yet