Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions patches/react-native-tab-view/details.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,16 @@
```
- 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

### [react-native-tab-view+4.3.0+005+fix-pager-scrollleft-91610.patch](react-native-tab-view+4.3.0+005+fix-pager-scrollleft-91610.patch)

- Reason:
```
On web, the pager's overflow:hidden clip container could pick up a stray scrollLeft from the auto-focused
Search input while the RHP was translated wide. The pager positions its pages with a transform and never
with scroll, so this leftover scrollLeft shifted the active per-diem page left and clipped the first column
(e.g. the first letters of country names). This patch pins the pager's scrollLeft to 0 on web.
```
- Upstream PR/issue: 🛑
- E/App issue: https://github.com/Expensify/App/issues/91610
- PR Introducing Patch: [#97754](https://github.com/Expensify/App/pull/97754)
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/node_modules/react-native-tab-view/lib/module/TabView.js b/node_modules/react-native-tab-view/lib/module/TabView.js
index 0000004..0000005 100644
--- a/node_modules/react-native-tab-view/lib/module/TabView.js
+++ b/node_modules/react-native-tab-view/lib/module/TabView.js
@@ -41,6 +41,27 @@
height: 0,
...initialLayout
});
+ const pagerRef = React.useRef(null);
+ // #91610: the pager positions its pages with a transform, never with scroll. On web the browser can
+ // still scroll this overflow:hidden container horizontally to reveal a focused input while the sheet
+ // is translated wide, leaving a persistent scrollLeft that shifts the active page left and clips its
+ // first column. Pin scrollLeft at 0.
+ React.useEffect(() => {
+ if (Platform.OS !== 'web') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Import Platform before using it in the patch

When this patch is applied, every TabView mount will run this effect and evaluate Platform.OS, but the hunk does not add Platform to TabView.js's React Native import. Since Platform is not otherwise defined in this module, the app will throw a ReferenceError as soon as any patched tab view mounts instead of just fixing the web scroll offset.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one's a false positive I think — TabView.js already imports Platform up top (line 4, import { I18nManager, Platform, StyleSheet, View } from 'react-native') and already uses it elsewhere in the file, like the RTL check around line 36. So the patch is just adding another Platform.OS check where it's already in scope, no ReferenceError.

+ return;
+ }
+ const node = pagerRef.current;
+ if (!node) {
+ return;
+ }
+ const reset = () => {
+ if (node.scrollLeft !== 0) {
+ node.scrollLeft = 0;
+ }
+ };
+ node.addEventListener('scroll', reset);
+ return () => node.removeEventListener('scroll', reset);
+ }, []);
const jumpToIndex = index => {
if (index !== navigationState.index) {
onIndexChange(index);
@@ -66,6 +87,7 @@
...sceneOptions?.[route.key]
}]));
return /*#__PURE__*/_jsx(View, {
+ ref: pagerRef,
onLayout: handleLayout,
style: [styles.pager, style],
children: /*#__PURE__*/_jsx(Pager, {
Loading