fix(overlays): only teardown when overlayCtrl defined

This commit is contained in:
Thijs Louisse 2020-07-04 18:50:22 +02:00
parent e04ae769ea
commit 121e1562fa

View file

@ -158,6 +158,10 @@ export const OverlayMixin = dedupeMixin(
super.disconnectedCallback(); super.disconnectedCallback();
} }
if (!this._overlayCtrl) {
return;
}
this._overlayDisconnectComplete = new Promise((resolve, reject) => { this._overlayDisconnectComplete = new Promise((resolve, reject) => {
this.__resolveOverlayDisconnectComplete = resolve; this.__resolveOverlayDisconnectComplete = resolve;
this.__rejectOverlayDisconnectComplete = reject; this.__rejectOverlayDisconnectComplete = reject;
@ -168,16 +172,14 @@ export const OverlayMixin = dedupeMixin(
this.__resolveOverlayDisconnectComplete(); this.__resolveOverlayDisconnectComplete();
}); });
if (this._overlayCtrl) { // We need to prevent that we create a setup/teardown cycle during startup, where it
// We need to prevent that we create a setup/teardown cycle during startup, where it // is common that the overlay system moves around nodes. Therefore, we make the
// is common that the overlay system moves around nodes. Therefore, we make the // teardown async, so that it only happens when we are permanently disconnecting from dom
// teardown async, so that it only happens when we are permanently disconnecting from dom this._overlayDisconnectComplete
this._overlayDisconnectComplete .then(() => {
.then(() => { this._teardownOverlayCtrl();
this._teardownOverlayCtrl(); })
}) .catch(() => {});
.catch(() => {});
}
} }
get _overlayInvokerNode() { get _overlayInvokerNode() {