TypeScript
fix(mobile): review's empty state stays below the header on iOS (#22420)
Claudesaulb47d71da28a4
diff --git a/apps/mobile/src/features/review/ReviewSheet.tsx b/apps/mobile/src/features/review/ReviewSheet.tsxindex 359ea229cb8..15dd6c7cb80 100644--- a/apps/mobile/src/features/review/ReviewSheet.tsx+++ b/apps/mobile/src/features/review/ReviewSheet.tsx@@ -487,6 +487,16 @@ export function ReviewSheet(props: ReviewSheetProps) {await refreshSelectedSection();setIsPullRefreshing(false);};+ const isRefreshing = isPullRefreshing || isSelectedSectionPending || areFilePatchesPending;+ // A refresh that starts programmatically adds its height to the native top inset and+ // subtracts it when it ends. If topContentInset changes in between, the inset ends up+ // short and the content sits under the header, so the fallback ScrollView starts over.+ const [fallbackInset, setFallbackInset] = useState(topContentInset);+ const [fallbackScrollViewKey, setFallbackScrollViewKey] = useState(0);+ if (fallbackInset !== topContentInset) {+ setFallbackInset(topContentInset);+ if (isRefreshing) setFallbackScrollViewKey((key) => key + 1);+ }const reviewFileNavigatorRef = useRef<ReviewFileNavigatorHandle>(null);const reviewFiles = parsedDiff.kind === "files" ? parsedDiff.files : [];const fileVisibility = useReviewFileVisibility({@@ -747,6 +757,7 @@ export function ReviewSheet(props: ReviewSheetProps) {</View>) : (<ScrollView+ key={fallbackScrollViewKey}contentContainerStyle={Platform.OS === "android" && (parsedDiff.kind === "empty" || !selectedSection)? { flexGrow: 1, justifyContent: "center" }@@ -762,7 +773,7 @@ export function ReviewSheet(props: ReviewSheetProps) {refreshControl={// Fallback and empty states need refresh controls; only Android has an explicit refresh menu.<RefreshControl- refreshing={isPullRefreshing || isSelectedSectionPending || areFilePatchesPending}+ refreshing={isRefreshing}onRefresh={() => void handlePullToRefresh()}/>}