I'm submitting a ... (check one with "x")
[x] bug report => Search github for a similar issue or PR before submitting
Plunkr Case (Bug Reports)
https://github-df7qmz.stackblitz.io/
Current behavior
When the dialog is not visible, hiding its containing element via ngIf (causing dialog OnDestroy) causes an error when using the appendTo attribute
Expected behavior
I'm not sure exactly what is supposed to happen here, but not the error of course :)
Maybe old code that tries to put the dialog back in its "non-body appended" place but with the dialog getting removed from the DOM in 6.0.2 that isn't a thing anymore. Anyway, you guys get it.
Minimal reproduction of the problem with instructions
In stackblitz, show the dialog. Toggle the container back and forth, everything is fine. Hide the dialog, and as soon as you hide the container you get the error.
ERROR TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
at Dialog.restoreAppend (dialog.ts:555)
at Dialog.ngOnDestroy (dialog.ts:590)
+1
+1
+1
+1
+1
@cagataycivici
A temporary fix is change the function restoreAppend in dialog.js in node_modules
change
if (this.appendTo) {
this.el.nativeElement.appendChild(this.container);
}
to
if (this.appendTo && this.container) {
this.el.nativeElement.appendChild(this.container);
}
The problem occours if you use an overlaypanel. The temporary fix from @jmesa-sistel also works, if you patch the file overlaypanel.js in primeng/components/overlaypanel/
Resolved for 6.1.0-rc.1 (due tomorrow)
appendTo={document.body} -- worked perfectly for me.
Most helpful comment
@cagataycivici
A temporary fix is change the function restoreAppend in dialog.js in node_modules
change
to