fix(overlays): fix OverlayController being added to a target that is already removed

This commit is contained in:
pndewit 2023-11-02 15:40:34 +01:00 committed by GitHub
parent 6296e51a12
commit 60312054c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/overlays': patch
---
fix(overlays): fix OverlayController being added to a target that is already removed

View file

@ -166,7 +166,8 @@ export const OverlayMixinImplementation = superclass =>
// we do a setup after every connectedCallback as firstUpdated will only be called once // we do a setup after every connectedCallback as firstUpdated will only be called once
this.__needsSetup = true; this.__needsSetup = true;
this.updateComplete.then(() => { this.updateComplete.then(() => {
if (this.__needsSetup) { // The overlay can already be removed during the update, so let's make sure it is still connected
if (this.__needsSetup && this.isConnected) {
this._setupOverlayCtrl(); this._setupOverlayCtrl();
} }
this.__needsSetup = false; this.__needsSetup = false;
@ -174,9 +175,8 @@ export const OverlayMixinImplementation = superclass =>
} }
disconnectedCallback() { disconnectedCallback() {
if (super.disconnectedCallback) { super.disconnectedCallback();
super.disconnectedCallback();
}
if (this._overlayCtrl) { if (this._overlayCtrl) {
this._teardownOverlayCtrl(); this._teardownOverlayCtrl();
} }