Skip to content

Commit bab2bdb

Browse files
colebemisdgreif
authored andcommitted
Fix overflow issues in PageLayout.Content (primer#2075)
* Fix overflow issues in PageLayout.Content * Update PageLayout story * Prettier * Create gentle-countries-rest.md * Fix merge errors * Update src/PageLayout/PageLayout.tsx * Update snapshot Co-authored-by: Dusty Greif <dustin.greif@gmail.com>
1 parent 51f0b4a commit bab2bdb

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

.changeset/gentle-countries-rest.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Fix overflow issues in `PageLayout.Content`
6+
7+
| Before | After |
8+
|--------|--------|
9+
| <img width="1224" alt="image" src="https://user-images.githubusercontent.com/3026298/167502059-81e0ef9e-2fd6-40fe-b1f1-708368286578.png"> | <img width="1247" alt="image" src="https://user-images.githubusercontent.com/3026298/167502084-1c4f247e-2713-4419-8f4c-bb1a20e24dca.png"> |

src/PageLayout/PageLayout.stories.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,21 @@ export const PullRequestPage = () => (
271271
</PageLayout.Header>
272272
<PageLayout.Content>
273273
<Box sx={{border: '1px solid', borderRadius: 2, borderColor: 'border.default', height: 200}}></Box>
274+
<Box
275+
sx={{
276+
maxWidth: '100%',
277+
overflowX: 'auto',
278+
border: '1px solid',
279+
whiteSpace: 'nowrap',
280+
borderColor: 'border.default',
281+
mt: 3,
282+
p: 3,
283+
borderRadius: 2
284+
}}
285+
>
286+
This box has really long content. If it is too long, it will cause x overflow and should show a scrollbar. When
287+
this overflows, it should not break to overall page layout!
288+
</Box>
274289
</PageLayout.Content>
275290
<PageLayout.Pane>
276291
<Box sx={{display: 'flex', flexDirection: 'column', gap: 3}}>

src/PageLayout/PageLayout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
2-
import {Box} from '..'
32
import {BetterSystemStyleObject, merge, SxProp} from '../sx'
3+
import {Box} from '..'
44

55
const REGION_ORDER = {
66
header: 0,
@@ -238,7 +238,8 @@ const Content: React.FC<PageLayoutContentProps> = ({width = 'full', children, sx
238238
// than the pane region on wide viewports if its contents are too wide.
239239
flexBasis: 0,
240240
flexGrow: 1,
241-
flexShrink: 1
241+
flexShrink: 1,
242+
minWidth: 1 // Hack to prevent overflowing content from pushing the pane region to the next line
242243
},
243244
sx
244245
)}

src/PageLayout/__snapshots__/PageLayout.test.tsx.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ exports[`PageLayout renders condensed layout 1`] = `
2828
-webkit-flex-shrink: 1;
2929
-ms-flex-negative: 1;
3030
flex-shrink: 1;
31+
min-width: 1px;
3132
}
3233
3334
.c5 {
@@ -246,6 +247,7 @@ exports[`PageLayout renders default layout 1`] = `
246247
-webkit-flex-shrink: 1;
247248
-ms-flex-negative: 1;
248249
flex-shrink: 1;
250+
min-width: 1px;
249251
}
250252
251253
.c5 {
@@ -491,6 +493,7 @@ exports[`PageLayout renders pane in different position when narrow 1`] = `
491493
-webkit-flex-shrink: 1;
492494
-ms-flex-negative: 1;
493495
flex-shrink: 1;
496+
min-width: 1px;
494497
}
495498
496499
.c5 {
@@ -729,6 +732,7 @@ exports[`PageLayout renders with dividers 1`] = `
729732
-webkit-flex-shrink: 1;
730733
-ms-flex-negative: 1;
731734
flex-shrink: 1;
735+
min-width: 1px;
732736
}
733737
734738
.c5 {

0 commit comments

Comments
 (0)