diff --git a/patches/react-native-tab-view/details.md b/patches/react-native-tab-view/details.md index 0ed399a7e1911..1e87cab148c3f 100644 --- a/patches/react-native-tab-view/details.md +++ b/patches/react-native-tab-view/details.md @@ -34,3 +34,14 @@ - Upstream PR/issue: 🛑 (must merge https://github.com/react-navigation/react-navigation/pull/12627 first) - E/App issue: https://github.com/Expensify/App/issues/71913#issuecomment-3584103273 - PR Introducing Patch: [#76586](https://github.com/Expensify/App/pull/76586) + +### [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) + +- Reason: + ``` + This patch fixes an issue on iOS native where the `onTabSelect` callback was not being called on initial mount + in the PagerViewAdapter. This mirrors the web fix from patch 003 (PanResponderAdapter) and ensures the input + field is auto-focused when opening the Start Chat screen on iOS. + ``` +- Upstream PR/issue: 🛑 (must merge https://github.com/react-navigation/react-navigation/pull/12627 first) +- E/App issue: https://github.com/Expensify/App/issues/83010 diff --git a/patches/react-native-tab-view/react-native-tab-view+4.1.0+004+fix-native-onTabSelect-on-mount.patch b/patches/react-native-tab-view/react-native-tab-view+4.1.0+004+fix-native-onTabSelect-on-mount.patch new file mode 100644 index 0000000000000..1c926949ef447 --- /dev/null +++ b/patches/react-native-tab-view/react-native-tab-view+4.1.0+004+fix-native-onTabSelect-on-mount.patch @@ -0,0 +1,26 @@ +diff --git a/node_modules/react-native-tab-view/src/PagerViewAdapter.tsx b/node_modules/react-native-tab-view/src/PagerViewAdapter.tsx +index d66b0cb..a1b2c3d 100644 +--- a/node_modules/react-native-tab-view/src/PagerViewAdapter.tsx ++++ b/node_modules/react-native-tab-view/src/PagerViewAdapter.tsx +@@ -57,3 +57,5 @@ export function PagerViewAdapter({ + const pagerRef = React.useRef(null); + const indexRef = React.useRef(index); + const navigationStateRef = React.useRef(navigationState); ++ const onTabSelectRef = React.useRef(onTabSelect); ++ const hasCalledInitialTabSelectRef = React.useRef(false); +@@ -64,3 +66,15 @@ export function PagerViewAdapter({ + React.useEffect(() => { + navigationStateRef.current = navigationState; ++ onTabSelectRef.current = onTabSelect; + }); ++ ++ React.useEffect(() => { ++ if (hasCalledInitialTabSelectRef.current) { ++ return; ++ } ++ hasCalledInitialTabSelectRef.current = true; ++ // Call onTabSelect on initial mount (parity with web PanResponderAdapter patch) ++ requestAnimationFrame(() => { ++ onTabSelectRef.current?.({index: navigationStateRef.current.index}); ++ }); ++ }, []);