diff --git a/.changeset/cyan-tigers-reply.md b/.changeset/cyan-tigers-reply.md new file mode 100644 index 00000000000..4d9855c38b2 --- /dev/null +++ b/.changeset/cyan-tigers-reply.md @@ -0,0 +1,5 @@ +--- +'@primer/react': patch +--- + +Fix PageLayout whitespace gap on narrow viewports. diff --git a/packages/react/src/PageLayout/PageLayout.module.css b/packages/react/src/PageLayout/PageLayout.module.css index 7c600dc3968..342dea83ef7 100644 --- a/packages/react/src/PageLayout/PageLayout.module.css +++ b/packages/react/src/PageLayout/PageLayout.module.css @@ -94,6 +94,10 @@ flex: 1 1 100%; flex-wrap: wrap; max-width: 100%; + + @media (--viewportRange-narrow) { + flex-direction: column; + } } .HorizontalDivider { diff --git a/packages/react/src/PageLayout/PageLayout.responsive.stories.tsx b/packages/react/src/PageLayout/PageLayout.responsive.stories.tsx index c32b9c6f9a4..a93aaea8cfd 100644 --- a/packages/react/src/PageLayout/PageLayout.responsive.stories.tsx +++ b/packages/react/src/PageLayout/PageLayout.responsive.stories.tsx @@ -307,3 +307,42 @@ SSRSafeResponsive.parameters = { }, }, } + +/** + * Regression test for whitespace gap issue on narrow viewports. + * @see https://github.com/github/primer/issues/6253 + * + * **The bug:** When PageLayout has a fixed/forced height (e.g., `height: 100%`) and the viewport is narrow, + * the PageLayoutContent container becomes taller than its children need. + * With `flex-direction: row` + `flex-wrap: wrap`, the extra vertical space is distributed as a gap + * around the wrapped rows (due to default `align-content: stretch`), causing a visible whitespace gap above the pane. + * + * **The fix:** On narrow viewports, `flex-direction: column` ensures items stack vertically without row-based distribution. + * Extra space is absorbed by `flex-grow` on the content instead of appearing as a gap. + */ + +export const FixedHeightResponsive: StoryFn = () => ( +