Skip to content

Commit db58e05

Browse files
vaadin-bottomivirkkijouni
authored
fix: prevent scroller content overflow when it has 100% height (#10622) (#10630)
Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com> Co-authored-by: Jouni Koivuviita <jouni@vaadin.com>
1 parent 7d6983e commit db58e05

File tree

3 files changed

+64
-3
lines changed

3 files changed

+64
-3
lines changed

packages/scroller/src/styles/vaadin-scroller-base-styles.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const scrollerStyles = css`
1919
outline: none;
2020
flex: 1;
2121
box-sizing: border-box;
22-
padding: 0 var(--vaadin-scroller-padding-inline);
22+
padding: var(--vaadin-scroller-padding-block) var(--vaadin-scroller-padding-inline);
2323
}
2424
2525
:host([focus-ring]) {
@@ -58,11 +58,15 @@ export const scrollerStyles = css`
5858
}
5959
6060
:host::before {
61-
margin-bottom: calc(var(--vaadin-scroller-padding-block) - var(--_indicator-height));
61+
top: 0;
62+
margin-bottom: calc(var(--_indicator-height) * -1);
63+
translate: 0 calc(var(--vaadin-scroller-padding-block) * -1);
6264
}
6365
6466
:host::after {
65-
margin-top: calc(var(--vaadin-scroller-padding-block) - var(--_indicator-height));
67+
bottom: 0;
68+
margin-top: calc(var(--_indicator-height) * -1);
69+
translate: 0 calc(var(--vaadin-scroller-padding-block) * 1);
6670
}
6771
6872
:host([overflow~='top'])::before {

packages/scroller/test/scroller.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,34 @@ describe('vaadin-scroller', () => {
147147
expect(scroller.getAttribute('overflow')).to.equal('top');
148148
});
149149
});
150+
151+
describe('full height content', () => {
152+
let container;
153+
154+
beforeEach(async () => {
155+
container = fixtureSync(`
156+
<div style="display: flex; flex-direction: column; height: 300px;">
157+
<vaadin-scroller style="--vaadin-scroller-padding-block: 16px; --vaadin-scroller-padding-inline: 16px;">
158+
<div style="height: 100%;">Content</div>
159+
</vaadin-scroller>
160+
</div>
161+
`);
162+
scroller = container.querySelector('vaadin-scroller');
163+
await nextRender();
164+
});
165+
166+
it('should not overflow when content has height 100%', () => {
167+
const content = scroller.querySelector('div');
168+
const scrollerRect = scroller.getBoundingClientRect();
169+
const contentRect = content.getBoundingClientRect();
170+
171+
// Content bottom should not exceed scroller bottom
172+
expect(contentRect.bottom).to.be.at.most(scrollerRect.bottom);
173+
});
174+
175+
it('should not create scrollable area when content has height 100%', () => {
176+
// If pseudo-elements don't affect layout, scrollHeight should equal clientHeight
177+
expect(scroller.scrollHeight).to.equal(scroller.clientHeight);
178+
});
179+
});
150180
});

packages/tabsheet/test/tabsheet.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,33 @@ describe('tabsheet - lazy tabs', () => {
401401
});
402402
});
403403

404+
describe('tabsheet - full height content', () => {
405+
let tabsheet;
406+
407+
beforeEach(async () => {
408+
tabsheet = fixtureSync(`
409+
<vaadin-tabsheet style="height: 300px;">
410+
<vaadin-tabs slot="tabs">
411+
<vaadin-tab id="tab-1">Tab 1</vaadin-tab>
412+
</vaadin-tabs>
413+
414+
<div tab="tab-1" style="height: 100%;">Panel 1</div>
415+
</vaadin-tabsheet>
416+
`);
417+
418+
await nextFrame();
419+
});
420+
421+
it('should not overflow when panel has height 100%', () => {
422+
const panel = tabsheet.querySelector('[tab="tab-1"]');
423+
const tabsheetRect = tabsheet.getBoundingClientRect();
424+
const panelRect = panel.getBoundingClientRect();
425+
426+
// Panel bottom should not exceed tabsheet bottom
427+
expect(panelRect.bottom).to.be.at.most(tabsheetRect.bottom);
428+
});
429+
});
430+
404431
describe('tabsheet - tabs without ID', () => {
405432
let tabsheet, tabs;
406433

0 commit comments

Comments
 (0)