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

ConfirmDialog - ExpressionChangedAfterItHasBeenCheckedError (when used with p-checkbox) #4982

Closed
fxmfr opened this issue Jan 26, 2018 · 14 comments

Comments

@fxmfr
Copy link

fxmfr commented Jan 26, 2018

I'm submitting a ...

[X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)

http://plnkr.co/edit/w9xuZEmNzV5HM5fez8hs?p=preview

Current behavior
ExpressionChangedAfterItHasBeenCheckedError is thrown when confirm dialog is opened from p-checkbox event. Probably other components (dropdown, input switch) are affected as well - see #4139 for details/example.

Expected behavior
Showing the confirm dialog should not throw ExpressionChangedAfterItHasBeenCheckedError.

Minimal reproduction of the problem with instructions
In plunker above, toggle checkbox and take a look at the console.

What is the motivation / use case for changing the behavior?
Avoid ExpressionChangedAfterItHasBeenCheckedError.

Please tell us about your environment:
Windows 10

  • Angular version: 5.0.0

  • PrimeNG version: 5.0.2

  • Browser: Chrome 63

  • Language: TypeScript 2.6.2

@cagataycivici
Copy link
Member

Try with Angular 5.2.x please.

@JacobSiegle
Copy link
Contributor

Having the same issue on Angular 5.2.X using Primeng 5.2.0-rc.2 from input switch. Tried his plunker replacing 5.0.0 with 5.2.0 and got the same result.

http://plnkr.co/edit/mBxNY8ct9oVW92YGDGVc?p=preview

@tbertran
Copy link

tbertran commented Feb 1, 2018

Updated Plunker to latest releases of Angular (5.2.3) and PrimeNG (5.2.0) and still getting the error
http://plnkr.co/edit/3m5FiVGGn9B7PjA9qSEg?p=preview

image

@brian428
Copy link
Contributor

brian428 commented Feb 8, 2018

Same error here. Important to note that it works fine with PrimeNG 5.0.2. Only 5.2 is now throwing these errors.

@brian428
Copy link
Contributor

brian428 commented Feb 9, 2018

@cagataycivici just wanted to point out that this issue (also noted in #5004) is completely blocking us from upgrading to 5.2. It's affecting virtually all of our Dialogs.

@cinnest
Copy link

cinnest commented Feb 12, 2018

Same problem here. As brian428 mentioned, the problem came with the upgrade to PrimeNG (5.2.0) and affects our Dialogs as well.

@brian428
Copy link
Contributor

Appears to be caused by #4686.

@polakv93
Copy link

polakv93 commented Mar 1, 2018

This is probably angular issue angular/angular#6005 (comment)
I had similar problem and after enableProdMode( ) system doesn't throw an error.

@brian428
Copy link
Contributor

brian428 commented Mar 1, 2018

As I said in the other thread: I don't think so. Prod mode doesn't do the check for values changing while change detection is happening, but that doesn't mean it isn't happening. Just that the error isn't being thrown. The PrimeNG code needs to change to ensure that values aren't changing during change detection (which didn't start happening until PrimeNG 5.2).

@cagataycivici
Copy link
Member

#5004

@ARandomDude
Copy link

ARandomDude commented Mar 28, 2018

I still get this error. #5004 does not fix it.
(See: http://plnkr.co/edit/bDUXw6Cs7X24CmWkirtQ (PrimeNG 5.2.3))

@ARandomDude
Copy link

ARandomDude commented Mar 28, 2018

I've got a workaround/fix for this. You can monkey-patch the ConfirmDialog like the this:

ConfirmDialog.prototype.ngAfterViewChecked = function () {
    if (this.executePostShowActions) {
        setTimeout(() => {
            this.domHandler.findSingle(this.el.nativeElement.children[0], 'button').focus();
            this.executePostShowActions = false;
        }, 0);
    }
}

Just put this code into one of your TS files.

@joelr2m
Copy link

joelr2m commented Apr 25, 2018

Any update on this? I get this one a hotspot checkbox which crashes the whole application.

@ESubrado
Copy link

ESubrado commented Apr 27, 2018

I once got "ExpressionChangedAfterItHasBeenCheckedError" when firing p-confirmDialog on dropdown. What i did is to just add [ConfirmationService] as a provider to the component page where p-confirmDialog exists.

This is supposed to be working if this is added to the app.module, but I guess due to complexity of code, the build wasn't able to detect that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants