Skip to content

Commit

Permalink
fix(overlays): fix OverlayController being added to a target that is …
Browse files Browse the repository at this point in the history
…already removed
  • Loading branch information
pndewit authored Nov 2, 2023
1 parent 6296e51 commit 6031205
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-months-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lion/overlays': patch
---

fix(overlays): fix OverlayController being added to a target that is already removed
8 changes: 4 additions & 4 deletions packages/overlays/src/OverlayMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,17 @@ export const OverlayMixinImplementation = superclass =>
// we do a setup after every connectedCallback as firstUpdated will only be called once
this.__needsSetup = true;
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.__needsSetup = false;
});
}

disconnectedCallback() {
if (super.disconnectedCallback) {
super.disconnectedCallback();
}
super.disconnectedCallback();

if (this._overlayCtrl) {
this._teardownOverlayCtrl();
}
Expand Down

0 comments on commit 6031205

Please sign in to comment.