Primeng: ConfirmDialogue ViewDestroyError on V9.0.0

Created on 12 Mar 2020  路  7Comments  路  Source: primefaces/primeng

When p-confirmDialog component is placed on a page and I try to navigate to other page it gives error
ERROR Error: Uncaught (in promise): Error: ViewDestroyedError: Attempt to use a destroyed view: detectChanges
Error: ViewDestroyedError: Attempt to use a destroyed view: detectChanges
at viewDestroyedError (core.js:30374)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:46938)
at checkAndUpdateView (core.js:45952)
at callWithDebugContext (core.js:47314)
at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.js:46876)
at ViewRef_.detectChanges (core.js:32689)
at ConfirmDialog.disableModality (primeng-confirmdialog.js:151)
at ConfirmDialog.onOverlayHide (primeng-confirmdialog.js:221)
at ConfirmDialog.ngOnDestroy (primeng-confirmdialog.js:227)
at callProviderLifecycles (core.js:33675)
at resolvePromise (zone-evergreen.js:793)
at resolvePromise (zone-evergreen.js:752)
at zone-evergreen.js:854
at ZoneDelegate.invokeTask (zone-evergreen.js:400)
at Object.onInvokeTask (core.js:41224)
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:570)
at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:485)
at invokeTask (zone-evergreen.js:1596)

  • Angular CLI: 9.0.3
  • Node: 12.14.1
  • OS: win32 x64
    Angular: 9.0.3

Most helpful comment

I'm having this issue in 9.1.3; any idea how to fix?

ERROR Error: ViewDestroyedError: Attempt to use a destroyed view: detectChanges at viewDestroyedError (core.js:30534) at Object.debugUpdateDirectives [as updateDirectives] (core.js:47483) at checkAndUpdateView (core.js:46494) at callWithDebugContext (core.js:47865) at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.js:47421) at ViewRef_.detectChanges (core.js:32883) at ConfirmDialog.disableModality (primeng-confirmdialog.js:304) at ConfirmDialog.onOverlayHide (primeng-confirmdialog.js:377) at ConfirmDialog.ngOnDestroy (primeng-confirmdialog.js:383) at callProviderLifecycles (core.js:33886)

All 7 comments

Current version of PrimeNg is 9.0.0. I have seen 8585 but can not understand how can i fix it. Please guide me in detail

As in post mentioned to add _wSpyDisableModality = jest.spyOn(ConfirmDialog.prototype, 'disableModality').mockImplementation(() => {});
Where need to add this lines of code?

I have solved the issue by Commenting d.detectChanges in ConfirmDialogBox.js

I'm having this issue in 9.1.3; any idea how to fix?

ERROR Error: ViewDestroyedError: Attempt to use a destroyed view: detectChanges at viewDestroyedError (core.js:30534) at Object.debugUpdateDirectives [as updateDirectives] (core.js:47483) at checkAndUpdateView (core.js:46494) at callWithDebugContext (core.js:47865) at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.js:47421) at ViewRef_.detectChanges (core.js:32883) at ConfirmDialog.disableModality (primeng-confirmdialog.js:304) at ConfirmDialog.onOverlayHide (primeng-confirmdialog.js:377) at ConfirmDialog.ngOnDestroy (primeng-confirmdialog.js:383) at callProviderLifecycles (core.js:33886)

I'm having this same problem in 9.1.3

        this.confirmationService.confirm({
            message: "If there are unsaved changes, they will be lost. Do you want to continue?",
            header: "Confirmation",
            icon: "pi pi-exclamation-triangle",
            accept: () => { this.router.navigate(["home"]); },
            reject: () => { }
        });

Hi did you find a solution to this issue?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SchneMa picture SchneMa  路  3Comments

garethlewis picture garethlewis  路  3Comments

miresk picture miresk  路  3Comments

mitosandov picture mitosandov  路  3Comments

watalberto picture watalberto  路  3Comments