diff --git a/packages/select-rich/src/LionSelectRich.js b/packages/select-rich/src/LionSelectRich.js index 566e00fe4..808fedaea 100644 --- a/packages/select-rich/src/LionSelectRich.js +++ b/packages/select-rich/src/LionSelectRich.js @@ -206,16 +206,6 @@ export class LionSelectRich extends ScopedElementsMixin( this.__initInteractionStates(); } - disconnectedCallback() { - if (super.disconnectedCallback) { - super.disconnectedCallback(); - } - this.__teardownEventListeners(); - this.__teardownOverlay(); - this.__teardownInvokerNode(); - this.__teardownListboxNode(); - } - firstUpdated(changedProperties) { super.firstUpdated(changedProperties); @@ -689,11 +679,15 @@ export class LionSelectRich extends ScopedElementsMixin( this._scrollTargetNode.addEventListener('keydown', this.__preventScrollingWithArrowKeys); } - __teardownOverlay() { + _teardownOverlayCtrl() { + super._teardownOverlayCtrl(); this._overlayCtrl.removeEventListener('show', this.__overlayOnShow); this._overlayCtrl.removeEventListener('before-show', this.__overlayBeforeShow); this._overlayCtrl.removeEventListener('hide', this.__overlayOnHide); this._scrollTargetNode.removeEventListener('keydown', this.__overlayOnHide); + this.__teardownInvokerNode(); + this.__teardownListboxNode(); + this.__teardownEventListeners(); } __preventScrollingWithArrowKeys(ev) { diff --git a/packages/select-rich/test/lion-select-rich-dialog-integration.test.js b/packages/select-rich/test/lion-select-rich-dialog-integration.test.js new file mode 100644 index 000000000..685be2330 --- /dev/null +++ b/packages/select-rich/test/lion-select-rich-dialog-integration.test.js @@ -0,0 +1,53 @@ +import { OverlayMixin } from '@lion/overlays'; +import { LitElement } from 'lit-element'; +import { defineCE, fixture, html, expect, unsafeStatic } from '@open-wc/testing'; +import '../lion-select-rich.js'; +import '../lion-options.js'; +import '../lion-option.js'; + +const tagString = defineCE( + class extends OverlayMixin(LitElement) { + render() { + return html` + + +
+
content of the overlay
+
+ `; + } + }, +); +const tag = unsafeStatic(tagString); + +describe('Select Rich Integration tests', () => { + it('works inside a dialog', async () => { + let properlyInstantiated = false; + + try { + const nestedEl = await fixture(html` + + + Item 1 + Item 2 + + + `); + + await fixture(html` + <${tag} id="main"> +
+ open nested overlay: + ${nestedEl} +
+ + + `); + properlyInstantiated = true; + } catch (e) { + throw new Error(e); + } + + expect(properlyInstantiated).to.be.true; + }); +});