Skip to content

Commit

Permalink
Fix issue where scroll containers nested inside of PageLayout.Pane wo…
Browse files Browse the repository at this point in the history
…uld 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.
  • Loading branch information
radglob committed Dec 2, 2022
1 parent d2e824e commit e98bcdf
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-melons-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Fix issue where scroll containers nested inside of PageLayout.Pane would be hard to use on mobile.
23 changes: 23 additions & 0 deletions src/PageLayout/PageLayout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -717,4 +717,27 @@ export const ResizablePane: Story = () => (
</PageLayout>
)

export const ScrollContainerWithinPageLayoutPane: Story = () => (
<Box sx={{display: 'grid', gridTemplateRows: 'auto 1fr auto', height: '100vh'}}>
<Box sx={{overflow: 'auto'}}>
<Placeholder label="Above inner scroll container" height={120} />
<PageLayout rowGap="none" columnGap="none" padding="none" containerWidth="full">
<PageLayout.Pane position="start" padding="normal" divider="line" sticky>
<Box sx={{overflow: 'auto'}}>
<PageLayout.Pane padding="normal">
<Placeholder label="Inner scroll container" height={800} />
</PageLayout.Pane>
</Box>
</PageLayout.Pane>
<PageLayout.Content padding="normal" width="large">
<Box sx={{display: 'grid'}}>
<Placeholder label="Page content" height={1600} />
</Box>
</PageLayout.Content>
</PageLayout>
<Placeholder label="Beneath inner scroll container" height={120} />
</Box>
</Box>
)

export default meta
4 changes: 3 additions & 1 deletion src/PageLayout/PageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,9 @@ const Pane = React.forwardRef<HTMLDivElement, React.PropsWithChildren<PageLayout
? ['100%', null, 'clamp(var(--pane-min-width), var(--pane-width), var(--pane-max-width))']
: paneWidths[width],
padding: SPACING_MAP[padding],
overflow: 'auto',
[`@media screen and (min-width: ${theme.breakpoints[1]})`]: {
overflow: 'auto'
},

[`@media screen and (min-width: ${theme.breakpoints[3]})`]: {
'--pane-max-width': 'calc(100vw - 959px)'
Expand Down
12 changes: 4 additions & 8 deletions src/PageLayout/__snapshots__/PageLayout.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ exports[`PageLayout renders condensed layout 1`] = `
--pane-max-width: calc(100vw - 511px);
width: 100%;
padding: 0;
overflow: auto;
}
.c3 {
Expand Down Expand Up @@ -133,7 +132,7 @@ exports[`PageLayout renders condensed layout 1`] = `
@media screen and (min-width:768px) {
.c11 {
width: 256px;
overflow: auto;
}
}
Expand Down Expand Up @@ -351,7 +350,6 @@ exports[`PageLayout renders default layout 1`] = `
--pane-max-width: calc(100vw - 511px);
width: 100%;
padding: 0;
overflow: auto;
}
.c2 {
Expand Down Expand Up @@ -425,7 +423,7 @@ exports[`PageLayout renders default layout 1`] = `
@media screen and (min-width:768px) {
.c11 {
width: 256px;
overflow: auto;
}
}
Expand Down Expand Up @@ -644,7 +642,6 @@ exports[`PageLayout renders pane in different position when narrow 1`] = `
--pane-max-width: calc(100vw - 511px);
width: 100%;
padding: 0;
overflow: auto;
}
.c2 {
Expand Down Expand Up @@ -718,7 +715,7 @@ exports[`PageLayout renders pane in different position when narrow 1`] = `
@media screen and (min-width:768px) {
.c11 {
width: 256px;
overflow: auto;
}
}
Expand Down Expand Up @@ -913,7 +910,6 @@ exports[`PageLayout renders with dividers 1`] = `
--pane-max-width: calc(100vw - 511px);
width: 100%;
padding: 0;
overflow: auto;
}
.c2 {
Expand Down Expand Up @@ -987,7 +983,7 @@ exports[`PageLayout renders with dividers 1`] = `
@media screen and (min-width:768px) {
.c10 {
width: 256px;
overflow: auto;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ exports[`SplitPageLayout renders default layout 1`] = `
--pane-max-width: calc(100vw - 511px);
width: 100%;
padding: 16px;
overflow: auto;
}
.c2 {
Expand Down Expand Up @@ -173,7 +172,7 @@ exports[`SplitPageLayout renders default layout 1`] = `
@media screen and (min-width:768px) {
.c11 {
width: 256px;
overflow: auto;
}
}
Expand Down

0 comments on commit e98bcdf

Please sign in to comment.