diff --git a/.changeset/brown-mirrors-admire-2.md b/.changeset/brown-mirrors-admire-2.md new file mode 100644 index 000000000..c85895fe1 --- /dev/null +++ b/.changeset/brown-mirrors-admire-2.md @@ -0,0 +1,5 @@ +--- +'@lion/ui': patch +--- + +[form-core]: make focusableNode teardown defensive in case the node doesn't exist diff --git a/.changeset/brown-mirrors-admire.md b/.changeset/brown-mirrors-admire.md new file mode 100644 index 000000000..2a67ef978 --- /dev/null +++ b/.changeset/brown-mirrors-admire.md @@ -0,0 +1,5 @@ +--- +'@lion/ui': patch +--- + +[overlays]: make sure that edge cases where overlays are connected and immediately disconnected, are covered well diff --git a/packages/ui/components/overlays/test-suites/OverlayMixin.suite.js b/packages/ui/components/overlays/test-suites/OverlayMixin.suite.js index 00a71a252..1882763c6 100644 --- a/packages/ui/components/overlays/test-suites/OverlayMixin.suite.js +++ b/packages/ui/components/overlays/test-suites/OverlayMixin.suite.js @@ -1,5 +1,6 @@ import { unsafeStatic, + fixtureSync, nextFrame, aTimeout, defineCE, @@ -315,6 +316,33 @@ export function runOverlayMixinSuite({ tagString, tag, suffix = '' }) { expect(getComputedStyle(el._overlayCtrl.contentWrapperNode).display).not.to.equal('none'); }); + it('does not run setup when disconnected', async () => { + const el = /** @type {OverlayEl} */ ( + fixtureSync(html` + <${tag}> +
content
+ + + `) + ); + + const parentOfEl = /** @type {HTMLDivElement} */ (el.parentElement); + + // @ts-expect-error [allow-protected-in-tests] + const setupSpy = sinon.spy(el, '_setupOverlayCtrl'); + // In some client apps, this sync disconnect happens... + parentOfEl.removeChild(el); + await el.updateComplete; + expect(setupSpy.callCount).to.equal(0); + + // Now add el again... + parentOfEl.appendChild(el); + await el.updateComplete; + expect(setupSpy.callCount).to.equal(1); + + setupSpy.restore(); + }); + /** Prevent unnecessary reset side effects, such as show animation. See: https://github.com/ing-bank/lion/issues/1075 */ it('does not call updateConfig on equivalent config change', async () => { const el = /** @type {OverlayEl} */ (