Primeng: Dialog/OverlayPanel error when using appendTo

Created on 26 Jul 2018  路  9Comments  路  Source: primefaces/primeng

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)

defect

Most helpful comment

@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);
}

All 9 comments

+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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mitosandov picture mitosandov  路  3Comments

pchristou picture pchristou  路  3Comments

watalberto picture watalberto  路  3Comments

Helayxa picture Helayxa  路  3Comments

papiroca-tm picture papiroca-tm  路  3Comments