Skip to content

Commit ceb4337

Browse files
authored
Fix PageLayout whitespace gap on narrow viewports (#7439)
1 parent 43d1d89 commit ceb4337

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.changeset/cyan-tigers-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Fix PageLayout whitespace gap on narrow viewports.

packages/react/src/PageLayout/PageLayout.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
flex: 1 1 100%;
9595
flex-wrap: wrap;
9696
max-width: 100%;
97+
98+
@media (--viewportRange-narrow) {
99+
flex-direction: column;
100+
}
97101
}
98102

99103
.HorizontalDivider {

packages/react/src/PageLayout/PageLayout.responsive.stories.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,42 @@ SSRSafeResponsive.parameters = {
307307
},
308308
},
309309
}
310+
311+
/**
312+
* Regression test for whitespace gap issue on narrow viewports.
313+
* @see https://github.com/github/primer/issues/6253
314+
*
315+
* **The bug:** When PageLayout has a fixed/forced height (e.g., `height: 100%`) and the viewport is narrow,
316+
* the PageLayoutContent container becomes taller than its children need.
317+
* With `flex-direction: row` + `flex-wrap: wrap`, the extra vertical space is distributed as a gap
318+
* around the wrapped rows (due to default `align-content: stretch`), causing a visible whitespace gap above the pane.
319+
*
320+
* **The fix:** On narrow viewports, `flex-direction: column` ensures items stack vertically without row-based distribution.
321+
* Extra space is absorbed by `flex-grow` on the content instead of appearing as a gap.
322+
*/
323+
324+
export const FixedHeightResponsive: StoryFn = () => (
325+
<div style={{height: '100vh', display: 'flex', flexDirection: 'column'}}>
326+
<PageLayout
327+
containerWidth="full"
328+
columnGap="none"
329+
padding="none"
330+
style={{
331+
height: '100%',
332+
}}
333+
>
334+
<PageLayout.Pane position="start">
335+
<Placeholder height={300} label="Pane" />
336+
</PageLayout.Pane>
337+
<PageLayout.Content width="full" padding="none">
338+
<Placeholder height={300} label="Content" />
339+
</PageLayout.Content>
340+
</PageLayout>
341+
</div>
342+
)
343+
344+
FixedHeightResponsive.parameters = {
345+
viewport: {
346+
defaultViewport: 'mobile1', // 320px width
347+
},
348+
}

0 commit comments

Comments
 (0)