diff --git a/packages/popover/src/vaadin-popover-overlay.js b/packages/popover/src/vaadin-popover-overlay.js index 92fd465194..4f2d7570f8 100644 --- a/packages/popover/src/vaadin-popover-overlay.js +++ b/packages/popover/src/vaadin-popover-overlay.js @@ -48,10 +48,13 @@ class PopoverOverlay extends PopoverOverlayMixin(DirMixin(ThemableMixin(PolylitM [part='overlay'] { position: relative; overflow: visible; + max-height: 100%; } [part='content'] { overflow: auto; + box-sizing: border-box; + max-height: 100%; width: var(--_vaadin-popover-content-width); height: var(--_vaadin-popover-content-height); } diff --git a/packages/popover/test/basic.test.js b/packages/popover/test/basic.test.js index 2d4eb9a279..e39ec93ed2 100644 --- a/packages/popover/test/basic.test.js +++ b/packages/popover/test/basic.test.js @@ -413,6 +413,24 @@ describe('popover', () => { }); }); + describe('content overflow', () => { + beforeEach(async () => { + popover.renderer = (root) => { + root.textContent = new Array(1000).fill('foo').join(' '); + }; + popover.opened = true; + await nextRender(); + }); + + it('should limit overlay height if content overflows the viewport', () => { + expect(overlay.$.overlay.getBoundingClientRect().height).to.equal(overlay.getBoundingClientRect().height); + }); + + it('should limit content height if content overflows the viewport', () => { + expect(overlay.$.content.getBoundingClientRect().height).to.equal(overlay.getBoundingClientRect().height); + }); + }); + describe('closed event', () => { beforeEach(async () => { popover.opened = true;