diff --git a/packages/overlays/src/OverlayMixin.js b/packages/overlays/src/OverlayMixin.js index c8cae95dd..5c687dd94 100644 --- a/packages/overlays/src/OverlayMixin.js +++ b/packages/overlays/src/OverlayMixin.js @@ -158,6 +158,10 @@ export const OverlayMixin = dedupeMixin( super.disconnectedCallback(); } + if (!this._overlayCtrl) { + return; + } + this._overlayDisconnectComplete = new Promise((resolve, reject) => { this.__resolveOverlayDisconnectComplete = resolve; this.__rejectOverlayDisconnectComplete = reject; @@ -168,16 +172,14 @@ export const OverlayMixin = dedupeMixin( this.__resolveOverlayDisconnectComplete(); }); - if (this._overlayCtrl) { - // 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 - // teardown async, so that it only happens when we are permanently disconnecting from dom - this._overlayDisconnectComplete - .then(() => { - this._teardownOverlayCtrl(); - }) - .catch(() => {}); - } + // 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 + // teardown async, so that it only happens when we are permanently disconnecting from dom + this._overlayDisconnectComplete + .then(() => { + this._teardownOverlayCtrl(); + }) + .catch(() => {}); } get _overlayInvokerNode() {