Skip to content

Commit 8eaedf6

Browse files
fix(mobile): register the native sidebar list, and check each list's own scroll prop
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4fa990e commit 8eaedf6

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

‎apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import {
7878
THREAD_LIST_V2_SETTLED_PAGE_COUNT,
7979
type ThreadListV2ListItem,
8080
} from "./threadListV2";
81+
import { NativeScrollView } from "../../native/NativeScrollViewMarker";
8182

8283
type SidebarListItem =
8384
| ThreadListV2ListItem
@@ -720,8 +721,8 @@ function ThreadNavigationSidebarPane(
720721
<View className="flex-1">
721722
<SwipeableScrollGateProvider enabled={swipeEnabled}>
722723
<GestureDetector gesture={sidebarScrollGesture}>
723-
{/* oxlint-disable-next-line t3code/require-registered-list-scroll -- Only the non-native workspace layout (Android and the fallback) renders this sidebar, which has no native header to register with. */}
724724
<AnimatedLegendList
725+
renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined}
725726
itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}
726727
data={listItems}
727728
drawDistance={500}

‎oxlint-plugin-t3code/rules/require-registered-list-scroll.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ describe("t3code/require-registered-list-scroll", () => {
1717
`const el = <KeyboardAwareLegendList data={rows} ScrollViewComponent={FeedScrollView} />;`,
1818
);
1919

20+
rule.invalid(
21+
"reports a list given the other list's scroll prop",
22+
`const el = <LegendList data={rows} ScrollViewComponent={NativeScrollView} />;`,
23+
);
24+
2025
rule.invalid(
2126
"reports a list with the default scroll view",
2227
`const el = <AnimatedLegendList data={rows} renderItem={renderRow} />;`,

‎oxlint-plugin-t3code/rules/require-registered-list-scroll.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { defineRule } from "@oxlint/plugins";
22

3-
const LIST_COMPONENTS = new Set(["LegendList", "AnimatedLegendList", "KeyboardAwareLegendList"]);
43
// LegendList takes a render function; KeyboardAwareLegendList takes the component itself.
5-
const SCROLL_COMPONENT_PROPS = new Set(["renderScrollComponent", "ScrollViewComponent"]);
4+
const SCROLL_COMPONENT_PROP: Readonly<Record<string, string>> = {
5+
LegendList: "renderScrollComponent",
6+
AnimatedLegendList: "renderScrollComponent",
7+
KeyboardAwareLegendList: "ScrollViewComponent",
8+
};
69

710
// A screen's list must scroll in a scroll view registered with its header, or the header loses
811
// its scroll-edge blur (and, on the iPhone Duo, the blur's reach under the vertical bar).
@@ -17,18 +20,19 @@ export default defineRule({
1720
create(context) {
1821
return {
1922
JSXOpeningElement(node) {
20-
if (node.name.type !== "JSXIdentifier" || !LIST_COMPONENTS.has(node.name.name)) return;
23+
if (node.name.type !== "JSXIdentifier") return;
24+
const prop = SCROLL_COMPONENT_PROP[node.name.name];
25+
if (!prop) return;
2126
const registered = node.attributes.some(
2227
(attribute) =>
2328
attribute.type === "JSXAttribute" &&
2429
attribute.name.type === "JSXIdentifier" &&
25-
SCROLL_COMPONENT_PROPS.has(attribute.name.name),
30+
attribute.name.name === prop,
2631
);
2732
if (registered) return;
2833
context.report({
2934
node,
30-
message:
31-
"Pass renderScrollComponent (or ScrollViewComponent) so the list scrolls in a header-registered scroll view: NativeScrollView on iOS, or a component wrapping NativeScrollViewMarker. A list nested in another scroll surface or sheet can suppress this with a reason.",
35+
message: `Pass ${prop} so the list scrolls in a header-registered scroll view: NativeScrollView on iOS, or a component wrapping NativeScrollViewMarker. A list nested in another scroll surface or sheet can suppress this with a reason.`,
3236
});
3337
},
3438
};

0 commit comments

Comments
 (0)