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

ExpressionChangedAfterItHasBeenCheckedError when preselect a p-radioButton #7940

Closed
a-stangl opened this issue Jul 12, 2019 · 2 comments
Closed
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@a-stangl
Copy link

I'm submitting a ...

[x] bug report 
[ ] feature request
[ ] support request

Stackblitz demo

Minimal Angular 8/PrimeNg 8 app that demonstrates the issue

https://stackblitz.com/edit/angular-zhmbkf

Current behavior

Initially getting ExpressionChangedAfterItHasBeenCheckedError (exactly like in #3100) after upgrading to Angular 8 and PrimeNG 8. In Angular 7/PrimeNg 7 the error did not occur.

My 2 cents:

Looks like setting static to true in

@ViewChild('rb', { static: false }) inputViewChild: ElementRef;

(https://github.com/primefaces/primeng/blob/master/src/app/components/radiobutton/radiobutton.ts#L57)

resolves the issue.

Expected behavior

Well, no error would be nice :-)

Minimal reproduction of the problem with instructions
Just open the Stackblitz and you will see the error in the console

Please tell us about your environment:

  • Angular version: 8.1.1
  • PrimeNG version: 8.0.1
  • Browser: Chromium 75.0.3770.90

  • Language: TypeScript 3.4

@MustafaElKhalifa
Copy link

MustafaElKhalifa commented Jul 15, 2019

I was able to pass this issue by using setTimeOut
I set the default value in ngOnInit

ngOnInit() {
    setTimeout(()=>{
      this.formGroup.get('input_form_control_name').setValue('0');
    },0)
}

@a-stangl
Copy link
Author

a-stangl commented Jul 15, 2019

@MustafaElKhalifa yes, but this is a hack that triggers change detection for the whole application. Also not suitable for me as I would need to apply this to 20+ components. :`-(

@cagataycivici cagataycivici changed the title PrimeNg 8.0.1 ExpressionChangedAfterItHasBeenCheckedError when preselect a p-radioButton ExpressionChangedAfterItHasBeenCheckedError when preselect a p-radioButton Jul 24, 2019
@cagataycivici cagataycivici self-assigned this Jul 24, 2019
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Jul 24, 2019
@cagataycivici cagataycivici added this to the 8.0.2 milestone Jul 24, 2019
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
Development

No branches or pull requests

3 participants