Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where scroll containers nested inside of PageLayout.Pane would be hard to use on mobile. #2606

Merged
merged 11 commits into from
Dec 2, 2022
Merged
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