Handle appendTo attribute used in legacy dialog properly

This commit is contained in:
Hadi Nategh 2022-04-28 18:00:37 +02:00
parent 0758e17d24
commit 36f41a9470
2 changed files with 23 additions and 1 deletions

View File

@ -220,6 +220,7 @@ export class Et2Dialog extends Et2Widget(ScopedElementsMixin(SlotMixin(LionDialo
* Automatically destroy the dialog when it closes. Set to false to keep the dialog around. * Automatically destroy the dialog when it closes. Set to false to keep the dialog around.
*/ */
destroy_on_close: Boolean, destroy_on_close: Boolean,
appendTo: String
} }
} }
@ -435,7 +436,7 @@ export class Et2Dialog extends Et2Widget(ScopedElementsMixin(SlotMixin(LionDialo
get value() : Object get value() : Object
{ {
let value = this.__value; let value = this.__value;
if(this._template_widget) if(this._template_widget && this._template_widget.widgetContainer)
{ {
value = this._template_widget.getValues(this._template_widget.widgetContainer); value = this._template_widget.getValues(this._template_widget.widgetContainer);
} }

View File

@ -88,6 +88,27 @@ export class et2_dialog extends Et2Dialog
return super._getButtons(); return super._getButtons();
} }
_onOpen()
{
super._onOpen();
// move the overlay dialog into appendTo dom since we want it to be shown in that container
if (this.appendTo)
{
document.getElementsByClassName(this.appendTo.replace('.',''))[0].appendChild(this._cachedOverlayContentNode);
}
}
_onClose(ev: PointerEvent)
{
// revert the moved container back to its original position in order to be able to teardown the overlay properly
if (this.appendTo)
{
document.getElementsByClassName('global-overlays__overlay-container')[0].appendChild(this._cachedOverlayContentNode);
}
super._onClose(ev);
}
/** /**
* @deprecated * @deprecated
* @returns {any} * @returns {any}