Skip to content

Commit 6efe201

Browse files
committed
fix(mobile): Android PR tabs use their own top edge, not the status bar inset
Android lists start below the header and get no automatic insets, so subtracting the safe-area insets put headerEnd 50pt early and capped short tabs below it. Switching from the switcher's edge dropped the page, and the files jump stopped short.
1 parent 56e952c commit 6efe201

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
341341
const navigation = useNavigation();
342342
const insets = useSafeAreaInsets();
343343
const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
344+
// Only iOS lists run under the bars; Android lists start below the header.
345+
const barInsets = Platform.OS === "ios" ? insets : { top: 0, bottom: 0 };
344346
const params = route.params;
345347
usePullRequestEnvironmentFallback(params);
346348
const connected = usePullRequestConnected(params.environmentId);
@@ -362,7 +364,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
362364
// has its own offset, which only its next scroll would record here.
363365
const currentScrollOffset = useRef<{ tab: typeof section; offset: number }>({
364366
tab: "overview",
365-
offset: -insets.top,
367+
offset: -barInsets.top,
366368
});
367369
const bodyY = useRef(0);
368370
const [headerHeight, setHeaderHeight] = useState(0);
@@ -386,9 +388,9 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
386388
const current =
387389
currentScrollOffset.current.tab === from
388390
? currentScrollOffset.current.offset
389-
: (scrollOffsets.current[from] ?? -insets.top);
391+
: (scrollOffsets.current[from] ?? -barInsets.top);
390392
scrollOffsets.current[section] = current;
391-
const headerEnd = Math.max(-insets.top, bodyY.current - insets.top);
393+
const headerEnd = Math.max(-barInsets.top, bodyY.current - barInsets.top);
392394
const offset = pullRequestTabOffset(current, scrollOffsets.current[next], headerEnd);
393395
requestedSection.current = next;
394396
scrollOffsets.current[next] = offset;
@@ -442,7 +444,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
442444
});
443445
const jumpToFiles = () => {
444446
scrollViews.current.overview?.scrollToOffset({
445-
offset: bodyY.current + filesY.current - insets.top,
447+
offset: bodyY.current + filesY.current - barInsets.top,
446448
animated: true,
447449
});
448450
pendingFilesJump.current = false;
@@ -676,7 +678,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
676678
// UIKit owns the bar's inset, so a minimizing bar and a resized column
677679
// move the list in the same frame as the bar.
678680
contentInsetAdjustmentBehavior="automatic"
679-
contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
681+
contentInsetStartAdjustment={barInsets.top}
680682
// RN scrollTo clamps against raw insets and ignores the automatic bar inset.
681683
scrollToOverflowEnabled
682684
refreshControl={
@@ -697,7 +699,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
697699
pendingDescriptionJump.current = false;
698700
// Collapse changes the scroll range; restore the heading after that layout commits.
699701
scrollViews.current.overview?.scrollToOffset({
700-
offset: bodyY.current + descriptionY.current - insets.top,
702+
offset: bodyY.current + descriptionY.current - barInsets.top,
701703
animated: false,
702704
});
703705
}}
@@ -708,7 +710,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
708710
// Short tabs must still be tall enough to preserve the collapsed header.
709711
minHeight: Math.max(
710712
0,
711-
viewportHeight + headerHeight - insets.top - insets.bottom,
713+
viewportHeight + headerHeight - barInsets.top - barInsets.bottom,
712714
),
713715
}}
714716
data={[

0 commit comments

Comments
 (0)