Skip to content

Commit 816be82

Browse files
committed
Allow sidebars to scroll through [#172]
Changelog: fix
1 parent cf099c8 commit 816be82

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

  • apps/polycentric/src/common/components/layout

apps/polycentric/src/common/components/layout/Layout.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
KeyboardAvoidingView,
1515
Platform,
1616
Pressable,
17+
ScrollView as RNScrollView,
1718
useWindowDimensions,
1819
View,
1920
} from 'react-native';
@@ -142,7 +143,10 @@ function Screen({
142143
testID="layout-screen"
143144
style={[
144145
Atoms.flex_row,
145-
Atoms.flex_1,
146+
// Web: grow with content so the sidebars' containing block spans the
147+
// full scroll height, letting `position: sticky` pin them. Native
148+
// keeps a fixed viewport-height screen.
149+
isWeb ? { minHeight: '100%' } : Atoms.flex_1,
146150
{ backgroundColor: theme.palette.neutral_0 },
147151
{ paddingTop: insets.top },
148152
!isWeb && {
@@ -200,22 +204,23 @@ export const LeftSidebar = memo(function LeftSidebar({
200204
{ alignItems: 'flex-end' },
201205
]}
202206
>
203-
<View style={{ width: narrowSidebar ? 88 : 275 }}>
207+
<View style={{ width: narrowSidebar ? 88 : 275, height: '100%' }}>
204208
<View
205209
style={[
206210
{
207-
position: 'fixed',
211+
position: 'sticky',
208212
top: 0,
209-
height: '100%',
213+
height: '100vh',
210214
},
211215
]}
212216
>
213-
<View
214-
style={[
217+
<RNScrollView
218+
showsVerticalScrollIndicator={false}
219+
contentContainerStyle={[
215220
Atoms.justify_between,
216221
Atoms.align_center,
217-
Atoms.h_full,
218222
{
223+
minHeight: '100%',
219224
paddingHorizontal: narrowSidebar ? 0 : 30,
220225
width: narrowSidebar ? 88 : 275,
221226
},
@@ -280,7 +285,7 @@ export const LeftSidebar = memo(function LeftSidebar({
280285
>
281286
{identity && <IdentityFooter compact={narrowSidebar} />}
282287
</View>
283-
</View>
288+
</RNScrollView>
284289
</View>
285290
</View>
286291
</View>
@@ -293,13 +298,11 @@ export const RightSidebar = memo(function RightSidebar() {
293298
const marginRight = deviceWidth <= Breakpoints['2xl'] ? 10 : 70;
294299

295300
return (
296-
<View style={{ width, marginRight }}>
297-
{/* Pin to viewport on web so it stays visible while the primary
298-
column scrolls; the outer View reserves the row space. */}
301+
<View style={{ width, marginRight, height: '100%' }}>
299302
<View
300303
style={
301304
isWeb
302-
? { position: 'fixed', top: 0, height: '100%', width }
305+
? { position: 'sticky', top: 0, height: '100vh', width }
303306
: undefined
304307
}
305308
>

0 commit comments

Comments
 (0)