Skip to content

Commit be79fba

Browse files
fix(mobile): Android sheets scroll without per-feature platform checks
@expo/ui's RNHostView always reported nested scrolling, so an app bar's buttons were the first scroll target a Material bottom sheet found. Patch it to report nested scrolling only when its hosted content can scroll, and drop the content-before-header column reversals from Sheet.android and the Git and Files sheets. Pull-to-refresh moves into a components/ui RefreshControl that steps aside inside Android bottom sheets (marked by a BottomSheetContext the sheet hosts provide), replacing the Git overview's inline sheet detection. Fixes #33445 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a0efdae commit be79fba

27 files changed

Lines changed: 154 additions & 76 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createContext } from "react";
2+
3+
/** True inside a draggable bottom sheet, which owns the downward drag at the top of its content. */
4+
export const BottomSheetContext = createContext(false);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { use } from "react";
2+
// oxlint-disable-next-line eslint/no-restricted-imports -- The wrapper every screen must use.
3+
import { RefreshControl as NativeRefreshControl } from "react-native";
4+
import { View, type RefreshControlProps } from "react-native";
5+
6+
import { BottomSheetContext } from "./BottomSheetContext";
7+
8+
/**
9+
* A bottom sheet takes the pull at the top, and Material reads the swipe-refresh layout as unable
10+
* to scroll up, so the sheet collapses instead of scrolling back. Sheets get a plain wrapper that
11+
* keeps the layout style the scroll view hands its refresh control.
12+
*/
13+
export function RefreshControl(props: RefreshControlProps) {
14+
if (use(BottomSheetContext)) {
15+
return (
16+
<View collapsable={false} style={props.style}>
17+
{props.children}
18+
</View>
19+
);
20+
}
21+
return <NativeRefreshControl {...props} />;
22+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// oxlint-disable-next-line eslint/no-restricted-imports -- The wrapper every screen must use.
2+
export { RefreshControl } from "react-native";

‎apps/mobile/src/components/ui/Sheet.android.tsx‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { View } from "react-native";
33
import { FormSheet } from "react-native-screens";
44
import { useResolveClassNames } from "uniwind";
55
import { AppBar } from "./AppBar";
6+
import { BottomSheetContext } from "./BottomSheetContext";
67
import { RoutedFormSheetContext } from "./RoutedFormSheetContext";
78
import { ScreenContent } from "./ScreenContent";
89
import type { SheetProps } from "./Sheet.types";
@@ -21,22 +22,24 @@ export function Sheet(props: SheetProps) {
2122
onDismiss={props.onClose}
2223
onNativeDismiss={props.onClose}
2324
>
24-
<RoutedFormSheetContext value={false}>
25-
{/* Android FormSheet does not bound flex children. Material drags target the first scroll view, so place content before the header. */}
26-
<View collapsable={false} className="absolute inset-0 flex-col-reverse bg-header">
27-
<ScreenContent>{props.children}</ScreenContent>
28-
<AppBar
29-
sheet
30-
title={props.title}
31-
onBack={props.dismissDisabled ? undefined : () => setIsOpen(false)}
32-
hideBottomBorder
33-
/>
34-
<View
35-
pointerEvents="none"
36-
className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"
37-
/>
38-
</View>
39-
</RoutedFormSheetContext>
25+
<BottomSheetContext value>
26+
<RoutedFormSheetContext value={false}>
27+
{/* Android FormSheet does not bound flex children. */}
28+
<View collapsable={false} className="absolute inset-0 bg-header">
29+
<AppBar
30+
sheet
31+
title={props.title}
32+
onBack={props.dismissDisabled ? undefined : () => setIsOpen(false)}
33+
hideBottomBorder
34+
/>
35+
<ScreenContent>{props.children}</ScreenContent>
36+
<View
37+
pointerEvents="none"
38+
className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"
39+
/>
40+
</View>
41+
</RoutedFormSheetContext>
42+
</BottomSheetContext>
4043
</FormSheet>
4144
);
4245
}

‎apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
1616
import { AppBar } from "../../components/ui/AppBar";
1717
import { SymbolView } from "../../components/ui/AppSymbol";
1818
import { useMemo, useRef, type ComponentProps } from "react";
19-
import { RefreshControl, useWindowDimensions, View } from "react-native";
19+
import { useWindowDimensions, View } from "react-native";
20+
import { RefreshControl } from "../../components/ui/RefreshControl";
2021
import { GestureDetector, useNativeGesture } from "react-native-gesture-handler";
2122
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
2223

‎apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScroll
55
import { useAuth } from "@clerk/expo";
66
import { useNavigation } from "@react-navigation/native";
77
import { useState } from "react";
8-
import { RefreshControl, View } from "react-native";
8+
import { View } from "react-native";
9+
import { RefreshControl } from "../../components/ui/RefreshControl";
910
import { useSafeAreaInsets } from "react-native-safe-area-context";
1011

1112
import { reportAtomCommandResult, settlePromise } from "@t3tools/client-runtime/state/runtime";

‎apps/mobile/src/features/cloud/T3ConnectProfilePage.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import type { MenuAction } from "@react-native-menu/menu";
77
import type { EnvironmentId } from "@t3tools/contracts";
88
import type { RelayClientEnvironmentRecord } from "@t3tools/contracts/relay";
99
import { type ReactNode, useRef, useState } from "react";
10-
import { Pressable, RefreshControl, ScrollView, Text, View } from "react-native";
10+
import { Pressable, ScrollView, Text, View } from "react-native";
11+
import { RefreshControl } from "../../components/ui/RefreshControl";
1112

1213
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
1314
import { SymbolView } from "../../components/ui/AppSymbol";

‎apps/mobile/src/features/files/FileMarkdownPreview.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { getBrowseDirectoryPath } from "@t3tools/client-runtime/state/projects";
55
import { maskMarkdownFrontmatter } from "@t3tools/shared/markdownFrontmatter";
66
import { useState } from "react";
77
import { StackActions, useNavigation } from "@react-navigation/native";
8-
import { RefreshControl, ScrollView, View } from "react-native";
8+
import { ScrollView, View } from "react-native";
9+
import { RefreshControl } from "../../components/ui/RefreshControl";
910

1011
import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
1112
import { FONT_FAMILIES } from "../../lib/fontFamilies";

‎apps/mobile/src/features/files/FileTreeBrowser.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import type { ProjectEntry } from "@t3tools/contracts";
55
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
66
import { SymbolView } from "../../components/ui/AppSymbol";
77
import { useEffect, useRef, useState } from "react";
8-
import { Pressable, RefreshControl, View } from "react-native";
8+
import { Pressable, View } from "react-native";
9+
import { RefreshControl } from "../../components/ui/RefreshControl";
910

1011
import { AppText as Text } from "../../components/ui/AppText";
1112
import { PierreEntryIcon } from "../../components/PierreEntryIcon";

‎apps/mobile/src/features/files/SourceFileSurface.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import {
77
FlatList,
88
Platform,
99
Pressable,
10-
RefreshControl,
1110
ScrollView,
1211
Text as NativeText,
1312
useWindowDimensions,
1413
View,
1514
} from "react-native";
15+
import { RefreshControl } from "../../components/ui/RefreshControl";
1616
import { WebView } from "react-native-webview";
1717
import { useSafeAreaInsets } from "react-native-safe-area-context";
1818
import { AppText as Text } from "../../components/ui/AppText";

0 commit comments

Comments
 (0)