Skip to content

Commit cd1029f

Browse files
fix(mobile): Home and pull request lists let UIKit own their top inset
Home, the pull request list, pull request detail and reviewers set their top inset by hand from useSafeAreaInsets and pinned a resting offset in JS. On the iPhone Duo, iOS 27 minimizes the navigation bar on scroll down by default, which shrinks the safe area every frame; each change round- tripped through JS, moved the content a frame late, and UIKit read that as a reversed scroll that restored the bar. Home's sidebar stuttered in place. These lists now use contentInsetAdjustmentBehavior "automatic", like the thread feed, so UIKit moves the inset and offset in the same frame as the bar, through folds and column resizes too. That removes the manual contentInset props and useRestingTopOffset; bottom padding subtracts the safe area UIKit now adds. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 22dc1da commit cd1029f

6 files changed

Lines changed: 16 additions & 149 deletions

File tree

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import type { SavedRemoteConnection } from "../../lib/connection";
4545
import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
4646
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
4747
import { nativeHeaderScrollEdgeEffects } from "../../native/scrollEdgeEffects";
48-
import { useRestingTopOffset } from "../../native/useRestingTopOffset";
4948
import {
5049
useNativeColumnLayoutMetrics,
5150
useNativeLayoutMetrics,
@@ -218,9 +217,7 @@ function HomeTopContentSpacer() {
218217
}
219218

220219
function HomeScrollView(props: ComponentProps<typeof ScrollView>) {
221-
const insets = useSafeAreaInsets();
222220
const primaryColumn = use(NativePrimaryColumnContext);
223-
const restingOffset = useRestingTopOffset(insets.top, props);
224221
if (Platform.OS !== "ios") return <ScrollView {...props} />;
225222

226223
// v5 needs the actual content scroll view registered with its screen controller.
@@ -235,14 +232,8 @@ function HomeScrollView(props: ComponentProps<typeof ScrollView>) {
235232
>
236233
<ScrollView
237234
{...props}
238-
{...restingOffset}
239235
// UIKit's scroll-edge material needs the scroll view's own surface color.
240236
className={cn(props.className, primaryColumn ? "bg-drawer" : "bg-screen")}
241-
// Use the column's measured inset so UIKit recognizes the resting top.
242-
// Padding visually clears the bar but leaves the native scroll offset
243-
// past its edge, activating scroll-edge protection before any scroll.
244-
automaticallyAdjustContentInsets={false}
245-
contentInsetAdjustmentBehavior="never"
246237
/>
247238
</ScrollViewMarker>
248239
);
@@ -885,8 +876,9 @@ export function HomeScreen(props: HomeScreenProps) {
885876
ListEmptyComponent={v2ListEmpty}
886877
style={{ flex: 1 }}
887878
automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
888-
contentInsetAdjustmentBehavior="never"
889-
contentInset={Platform.OS === "ios" ? { top: insets.top } : undefined}
879+
// UIKit owns the bar's inset, so a minimizing bar and a resized column move
880+
// the list in the same frame as the bar.
881+
contentInsetAdjustmentBehavior="automatic"
890882
contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
891883
initialScrollOffset={
892884
initialScrollOffset > 0
@@ -905,7 +897,7 @@ export function HomeScreen(props: HomeScreenProps) {
905897
(contentSideInsets?.right ?? 0) + (primaryColumn ? 8 : 0) + androidListGutter,
906898
paddingBottom:
907899
Platform.OS === "ios"
908-
? iosBottomClearance
900+
? iosBottomClearance - (columnMetrics?.safeArea.bottom ?? insets.bottom)
909901
: (workspace?.bottomClearance ??
910902
Math.max(insets.bottom, 16) +
911903
(Platform.OS === "android" ? fabClearance : 88)),

‎apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { ScrollViewMarker } from "react-native-screens";
2020
import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
2121
import { EmptyState } from "../../components/ui/EmptyState";
2222
import { Button } from "../../components/ui/Button";
23-
import { useRestingTopOffset } from "../../native/useRestingTopOffset";
2423
import { SymbolView } from "../../components/ui/AppSymbol";
2524
import { NativeStackScreenOptions } from "../../native/StackHeader";
2625
import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
@@ -35,17 +34,9 @@ import { PullRequestAvatar } from "./PullRequestPresentation";
3534
import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";
3635

3736
function ReviewerScrollView(props: ScrollViewProps) {
38-
const insets = useSafeAreaInsets();
39-
const restingOffset = useRestingTopOffset(insets.top, props);
4037
return (
4138
<ScrollViewMarker style={{ flex: 1 }}>
42-
<ScrollView
43-
{...props}
44-
{...restingOffset}
45-
automaticallyAdjustContentInsets={false}
46-
contentInsetAdjustmentBehavior="never"
47-
contentInset={{ top: insets.top }}
48-
/>
39+
<ScrollView {...props} contentInsetAdjustmentBehavior="automatic" />
4940
</ScrollViewMarker>
5041
);
5142
}

‎apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ import {
5656
View,
5757
} from "react-native";
5858
import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
59-
import { useRestingTopOffset } from "../../native/useRestingTopOffset";
6059
import { useSafeAreaInsets } from "react-native-safe-area-context";
6160

6261
import { AppText as Text } from "../../components/ui/AppText";
@@ -117,16 +116,9 @@ import { usePullRequestEnvironmentFallback } from "./usePullRequestEnvironmentFa
117116
const EMPTY_IDS: readonly string[] = [];
118117

119118
function PullRequestTabScrollView(props: ScrollViewProps) {
120-
const insets = useSafeAreaInsets();
121-
const restingOffset = useRestingTopOffset(insets.top, props);
122119
return (
123120
<ScrollViewMarker style={{ flex: 1 }}>
124-
<ScrollView
125-
{...props}
126-
{...restingOffset}
127-
automaticallyAdjustContentInsets={false}
128-
contentInsetAdjustmentBehavior="never"
129-
/>
121+
<ScrollView {...props} />
130122
</ScrollViewMarker>
131123
);
132124
}
@@ -572,10 +564,9 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
572564
renderScrollComponent={
573565
Platform.OS === "ios" ? PullRequestTabScrollView : undefined
574566
}
575-
contentInsetAdjustmentBehavior="never"
576-
contentInset={
577-
Platform.OS === "ios" ? { top: insets.top, bottom: insets.bottom } : undefined
578-
}
567+
// UIKit owns the bar's inset, so a minimizing bar and a resized column
568+
// move the list in the same frame as the bar.
569+
contentInsetAdjustmentBehavior="automatic"
579570
contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
580571
refreshControl={
581572
<RefreshControl

‎apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
2121

2222
import { AppText as Text } from "../../components/ui/AppText";
2323
import { EmptyState } from "../../components/ui/EmptyState";
24-
import { useRestingTopOffset } from "../../native/useRestingTopOffset";
2524
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
2625
import { useWorkspaceState } from "../../state/workspace";
2726
import { useProjects } from "../../state/entities";
@@ -46,16 +45,9 @@ import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
4645
import { useAndroidWorkspaceSelection } from "../workspace/useAndroidWorkspaceSelection";
4746

4847
function PullRequestScrollView(props: ScrollViewProps) {
49-
const insets = useSafeAreaInsets();
50-
const restingOffset = useRestingTopOffset(insets.top, props);
5148
return (
5249
<ScrollViewMarker style={{ flex: 1 }}>
53-
<ScrollView
54-
{...props}
55-
{...restingOffset}
56-
automaticallyAdjustContentInsets={false}
57-
contentInsetAdjustmentBehavior="never"
58-
/>
50+
<ScrollView {...props} />
5951
</ScrollViewMarker>
6052
);
6153
}
@@ -266,16 +258,19 @@ export function PullRequestsScreen(
266258
showsVerticalScrollIndicator={Platform.OS !== "android"}
267259
recycleItems
268260
renderScrollComponent={Platform.OS === "ios" ? PullRequestScrollView : undefined}
269-
contentInsetAdjustmentBehavior="never"
270-
contentInset={Platform.OS === "ios" ? { top: insets.top } : undefined}
261+
// UIKit owns the bar's inset, so a minimizing bar and a resized column move
262+
// the list in the same frame as the bar.
263+
contentInsetAdjustmentBehavior="automatic"
271264
// A plain offset: LegendList adds the list header to an index-based restore, which
272265
// landed every return one header lower.
273266
initialScrollOffset={
274267
initialOffset > 0 ? initialOffset - (Platform.OS === "ios" ? insets.top : 0) : undefined
275268
}
276269
contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
277270
contentContainerStyle={{
278-
paddingBottom: Math.max(insets.bottom, workspace.bottomClearance),
271+
paddingBottom:
272+
Math.max(insets.bottom, workspace.bottomClearance) -
273+
(Platform.OS === "ios" ? insets.bottom : 0),
279274
}}
280275
onScroll={(event) => {
281276
workspace.recordScrollOffset(

‎apps/mobile/src/native/useRestingTopOffset.test.tsx‎

Lines changed: 0 additions & 73 deletions
This file was deleted.

‎apps/mobile/src/native/useRestingTopOffset.ts‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)