backport SL-2274

This commit is contained in:
Cory LaViska
2024-12-04 12:03:49 -05:00
parent 17fb0ef94e
commit c097b21443
2 changed files with 24 additions and 1 deletions

View File

@@ -1,8 +1,11 @@
import { expect } from '@open-wc/testing';
import { fixtures } from '../../internal/test/fixture.js';
import { html } from 'lit';
import type WaPopup from './popup.js';
describe('<wa-popup>', () => {
let element: WaPopup;
for (const fixture of fixtures) {
describe(`with "${fixture.type}" rendering`, () => {
it('should render a component', async () => {
@@ -10,6 +13,26 @@ describe('<wa-popup>', () => {
expect(el).to.exist;
});
it('should properly handle positioning when active changes', async () => {
element = await fixture(html`<wa-popup></wa-popup>`);
element.active = true;
await element.updateComplete;
// SImulate a scroll event
const event = new Event('scroll');
window.dispatchEvent(event);
element.active = false;
await element.updateComplete;
// The component should not throw an error when the window is scrolled
expect(() => {
element.active = true;
window.dispatchEvent(event);
}).not.to.throw();
});
});
}
});

View File

@@ -276,7 +276,7 @@ export default class WaPopup extends WebAwesomeElement {
private start() {
// We can't start the positioner without an anchor
if (!this.anchorEl) {
if (!this.anchorEl || !this.active) {
return;
}