Skip to content

Commit 7735cf2

Browse files
web-padawanclaude
andauthored
fix: stretch slotted content to full cross-axis size in master-detail-layout (#11364)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1e6c5de commit 7735cf2

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

dev/master-detail-layout.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
.master {
3535
box-sizing: border-box;
36-
height: 100%;
3736
padding: 1.5rem;
3837
overflow: auto;
3938
}
@@ -62,7 +61,6 @@
6261

6362
.static-detail {
6463
box-sizing: border-box;
65-
height: 100%;
6664
padding: 1.5rem;
6765
overflow: auto;
6866
}

packages/master-detail-layout/ARCHITECTURE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ In vertical mode, `grid-template-rows` replaces `grid-template-columns` using th
3838

3939
`--_master-size` and `--_detail-size` default to `30em` and `15em` respectively in `:host`. When `masterSize`/`detailSize` properties are set, JS overrides these CSS custom properties. When cleared, JS removes the inline style and the defaults apply again.
4040

41+
## Slotted Content Stretching
42+
43+
`::slotted(*) { height: 100% }` makes all slotted content stretch to fill the cross-axis by default. In horizontal mode, children fill the full height; in vertical mode, block elements already fill width naturally. This low-specificity rule is easily overridden by explicit height on slotted elements.
44+
4145
## Overflow Detection
4246

4347
`__checkOverflow()` reads the first 3 of the 4 computed track sizes: `[masterSize, masterExtra, detailSize]`. The 4th (detail extra) is 0 in overflow scenarios.

packages/master-detail-layout/src/styles/vaadin-master-detail-layout-base-styles.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export const masterDetailLayoutStyles = css`
3737
box-sizing: border-box;
3838
}
3939
40+
::slotted(*) {
41+
height: 100%;
42+
}
43+
4044
[part~='master'] {
4145
grid-column: master-start / detail-start;
4246
}

packages/master-detail-layout/test/master-detail-layout.test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@ describe('vaadin-master-detail-layout', () => {
114114
});
115115

116116
it('should trigger observer when a direct child is resized', async () => {
117+
let height = 100;
117118
for (const child of layout.children) {
118-
child.style.height = '100px';
119+
child.style.height = `${height}px`;
120+
height += 100;
119121
await onceResized(layout);
120122
expect(onResizeSpy).to.be.called;
121123
onResizeSpy.resetHistory();
@@ -152,5 +154,16 @@ describe('vaadin-master-detail-layout', () => {
152154
expect(parseFloat(getComputedStyle(master).height)).to.equal(500);
153155
expect(parseFloat(getComputedStyle(detail).height)).to.equal(500);
154156
});
157+
158+
it('should stretch slotted content to full height', async () => {
159+
layout.masterSize = '200px';
160+
layout.detailSize = '200px';
161+
layout.parentElement.style.height = '500px';
162+
await onceResized(layout);
163+
const masterContent = layout.querySelector(':not([slot])');
164+
const detailContent = layout.querySelector('[slot="detail"]');
165+
expect(masterContent.offsetHeight).to.equal(500);
166+
expect(detailContent.offsetHeight).to.equal(500);
167+
});
155168
});
156169
});

0 commit comments

Comments
 (0)