From c40fc313ca9dd66f9949c44f494d50951d96fe9d Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Tue, 10 Oct 2023 11:43:14 -0700 Subject: [PATCH] Fix iOS Paper Scroll Event RTL check (#40751) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/40751 In D48379915 I fixed inverted `contentOffset` in `onScroll` events on iOS. I thought I tested on Paper, but I think this was during a period where the Paper route in Catalyst was actually launching Fabric (oops). In Paper, at least under `forceRTL` and English, `[UIApplication sharedApplication].userInterfaceLayoutDirection` is not set to RTL. We instead have a per-view `reactLayoutDirection` we should be reading. This sort of thing isn't currently set on Fabric, which checks application-level RTL. This seems... not right with being able to set `direction` in a subtree context, but Android does the same thing, and that would take some greater changes. Changelog: [iOS][Fixed] - Fix iOS Paper Scroll Event RTL check Reviewed By: luluwu2032 Differential Revision: D50098310 fbshipit-source-id: e321fca7b2f7983e903e23237bc2d604c72f98a3 --- packages/react-native/React/Views/ScrollView/RCTScrollView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/React/Views/ScrollView/RCTScrollView.m b/packages/react-native/React/Views/ScrollView/RCTScrollView.m index 1b506c877eb..9e8b02708de 100644 --- a/packages/react-native/React/Views/ScrollView/RCTScrollView.m +++ b/packages/react-native/React/Views/ScrollView/RCTScrollView.m @@ -1058,7 +1058,7 @@ RCT_SET_AND_PRESERVE_OFFSET(setScrollIndicatorInsets, scrollIndicatorInsets, UIE } CGPoint offset = scrollView.contentOffset; - if ([UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) { + if ([self reactLayoutDirection] == UIUserInterfaceLayoutDirectionRightToLeft) { offset.x = scrollView.contentSize.width - scrollView.frame.size.width - offset.x; }