mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 04:09:12 +00:00
backport SL-2274
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user