Skip to content

Commit e98bcdf

Browse files
authored
Fix issue where scroll containers nested inside of PageLayout.Pane would be hard to use on mobile. (#2606)
* Set overflow: auto for PageLayout.Pane for larger screen sizes only, new storybook story for testing issues found in code tree. * Create two-melons-swim.md * Update test snapshots.
1 parent d2e824e commit e98bcdf

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed

.changeset/two-melons-swim.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 issue where scroll containers nested inside of PageLayout.Pane would be hard to use on mobile.

src/PageLayout/PageLayout.stories.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,4 +717,27 @@ export const ResizablePane: Story = () => (
717717
</PageLayout>
718718
)
719719

720+
export const ScrollContainerWithinPageLayoutPane: Story = () => (
721+
<Box sx={{display: 'grid', gridTemplateRows: 'auto 1fr auto', height: '100vh'}}>
722+
<Box sx={{overflow: 'auto'}}>
723+
<Placeholder label="Above inner scroll container" height={120} />
724+
<PageLayout rowGap="none" columnGap="none" padding="none" containerWidth="full">
725+
<PageLayout.Pane position="start" padding="normal" divider="line" sticky>
726+
<Box sx={{overflow: 'auto'}}>
727+
<PageLayout.Pane padding="normal">
728+
<Placeholder label="Inner scroll container" height={800} />
729+
</PageLayout.Pane>
730+
</Box>
731+
</PageLayout.Pane>
732+
<PageLayout.Content padding="normal" width="large">
733+
<Box sx={{display: 'grid'}}>
734+
<Placeholder label="Page content" height={1600} />
735+
</Box>
736+
</PageLayout.Content>
737+
</PageLayout>
738+
<Placeholder label="Beneath inner scroll container" height={120} />
739+
</Box>
740+
</Box>
741+
)
742+
720743
export default meta

src/PageLayout/PageLayout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,9 @@ const Pane = React.forwardRef<HTMLDivElement, React.PropsWithChildren<PageLayout
675675
? ['100%', null, 'clamp(var(--pane-min-width), var(--pane-width), var(--pane-max-width))']
676676
: paneWidths[width],
677677
padding: SPACING_MAP[padding],
678-
overflow: 'auto',
678+
[`@media screen and (min-width: ${theme.breakpoints[1]})`]: {
679+
overflow: 'auto'
680+
},
679681

680682
[`@media screen and (min-width: ${theme.breakpoints[3]})`]: {
681683
'--pane-max-width': 'calc(100vw - 959px)'

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ exports[`PageLayout renders condensed layout 1`] = `
6969
--pane-max-width: calc(100vw - 511px);
7070
width: 100%;
7171
padding: 0;
72-
overflow: auto;
7372
}
7473
7574
.c3 {
@@ -133,7 +132,7 @@ exports[`PageLayout renders condensed layout 1`] = `
133132
134133
@media screen and (min-width:768px) {
135134
.c11 {
136-
width: 256px;
135+
overflow: auto;
137136
}
138137
}
139138
@@ -351,7 +350,6 @@ exports[`PageLayout renders default layout 1`] = `
351350
--pane-max-width: calc(100vw - 511px);
352351
width: 100%;
353352
padding: 0;
354-
overflow: auto;
355353
}
356354
357355
.c2 {
@@ -425,7 +423,7 @@ exports[`PageLayout renders default layout 1`] = `
425423
426424
@media screen and (min-width:768px) {
427425
.c11 {
428-
width: 256px;
426+
overflow: auto;
429427
}
430428
}
431429
@@ -644,7 +642,6 @@ exports[`PageLayout renders pane in different position when narrow 1`] = `
644642
--pane-max-width: calc(100vw - 511px);
645643
width: 100%;
646644
padding: 0;
647-
overflow: auto;
648645
}
649646
650647
.c2 {
@@ -718,7 +715,7 @@ exports[`PageLayout renders pane in different position when narrow 1`] = `
718715
719716
@media screen and (min-width:768px) {
720717
.c11 {
721-
width: 256px;
718+
overflow: auto;
722719
}
723720
}
724721
@@ -913,7 +910,6 @@ exports[`PageLayout renders with dividers 1`] = `
913910
--pane-max-width: calc(100vw - 511px);
914911
width: 100%;
915912
padding: 0;
916-
overflow: auto;
917913
}
918914
919915
.c2 {
@@ -987,7 +983,7 @@ exports[`PageLayout renders with dividers 1`] = `
987983
988984
@media screen and (min-width:768px) {
989985
.c10 {
990-
width: 256px;
986+
overflow: auto;
991987
}
992988
}
993989

src/SplitPageLayout/__snapshots__/SplitPageLayout.test.tsx.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ exports[`SplitPageLayout renders default layout 1`] = `
104104
--pane-max-width: calc(100vw - 511px);
105105
width: 100%;
106106
padding: 16px;
107-
overflow: auto;
108107
}
109108
110109
.c2 {
@@ -173,7 +172,7 @@ exports[`SplitPageLayout renders default layout 1`] = `
173172
174173
@media screen and (min-width:768px) {
175174
.c11 {
176-
width: 256px;
175+
overflow: auto;
177176
}
178177
}
179178

0 commit comments

Comments
 (0)