Skip to content

Commit ec18bb3

Browse files
authored
Merge pull request Expensify#84002 from Expensify/claude-fixNativeOnTabSelectOnMount
Fix: Patch PagerViewAdapter to call onTabSelect on initial mount for native
2 parents c627215 + 9a093a2 commit ec18bb3

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

patches/react-native-tab-view/details.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,14 @@
3434
- Upstream PR/issue: 🛑 (must merge https://github.com/react-navigation/react-navigation/pull/12627 first)
3535
- E/App issue: https://github.com/Expensify/App/issues/71913#issuecomment-3584103273
3636
- PR Introducing Patch: [#76586](https://github.com/Expensify/App/pull/76586)
37+
38+
### [react-native-tab-view+4.1.0+004+fix-native-onTabSelect-on-mount.patch](react-native-tab-view+4.1.0+004+fix-native-onTabSelect-on-mount.patch)
39+
40+
- Reason:
41+
```
42+
This patch fixes an issue on iOS native where the `onTabSelect` callback was not being called on initial mount
43+
in the PagerViewAdapter. This mirrors the web fix from patch 003 (PanResponderAdapter) and ensures the input
44+
field is auto-focused when opening the Start Chat screen on iOS.
45+
```
46+
- Upstream PR/issue: 🛑 (must merge https://github.com/react-navigation/react-navigation/pull/12627 first)
47+
- E/App issue: https://github.com/Expensify/App/issues/83010
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/node_modules/react-native-tab-view/src/PagerViewAdapter.tsx b/node_modules/react-native-tab-view/src/PagerViewAdapter.tsx
2+
index d66b0cb..a1b2c3d 100644
3+
--- a/node_modules/react-native-tab-view/src/PagerViewAdapter.tsx
4+
+++ b/node_modules/react-native-tab-view/src/PagerViewAdapter.tsx
5+
@@ -57,3 +57,5 @@ export function PagerViewAdapter<T extends Route>({
6+
const pagerRef = React.useRef<ViewPager>(null);
7+
const indexRef = React.useRef<number>(index);
8+
const navigationStateRef = React.useRef(navigationState);
9+
+ const onTabSelectRef = React.useRef(onTabSelect);
10+
+ const hasCalledInitialTabSelectRef = React.useRef(false);
11+
@@ -64,3 +66,15 @@ export function PagerViewAdapter<T extends Route>({
12+
React.useEffect(() => {
13+
navigationStateRef.current = navigationState;
14+
+ onTabSelectRef.current = onTabSelect;
15+
});
16+
+
17+
+ React.useEffect(() => {
18+
+ if (hasCalledInitialTabSelectRef.current) {
19+
+ return;
20+
+ }
21+
+ hasCalledInitialTabSelectRef.current = true;
22+
+ // Call onTabSelect on initial mount (parity with web PanResponderAdapter patch)
23+
+ requestAnimationFrame(() => {
24+
+ onTabSelectRef.current?.({index: navigationStateRef.current.index});
25+
+ });
26+
+ }, []);

0 commit comments

Comments
 (0)