From e809e0aca713ad12f91778b09f5297f1da866b26 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 3 Jan 2024 04:33:23 -0800 Subject: [PATCH] Fix horizontal scrollview scrollTo coordinate space in RTL on oldarch (#42094) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42094 Fabric fixed this a while back with https://github.com/facebook/react-native/commit/9ca460f06405db85d0df60cbe53c304c9127c3bf Looks like this is still broken on Paper, and now VirtualizedList relies on it. https://github.com/facebook/react-native/pull/38737#discussion_r1437874601 Changelog: [ios][fixed] - Fix horizontal scrollview scrollTo coordinate space in RTL on oldarch Reviewed By: lenaic Differential Revision: D52451602 fbshipit-source-id: f41d8248c7f6ab23965800b09ca1082fd1a15151 --- packages/react-native/React/Views/ScrollView/RCTScrollView.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native/React/Views/ScrollView/RCTScrollView.m b/packages/react-native/React/Views/ScrollView/RCTScrollView.m index 3ad69069ef15d9..1aead514ac3fa5 100644 --- a/packages/react-native/React/Views/ScrollView/RCTScrollView.m +++ b/packages/react-native/React/Views/ScrollView/RCTScrollView.m @@ -568,6 +568,10 @@ - (void)scrollToOffset:(CGPoint)offset - (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated { + if ([self reactLayoutDirection] == UIUserInterfaceLayoutDirectionRightToLeft) { + offset.x = _scrollView.contentSize.width - _scrollView.frame.size.width - offset.x; + } + if (!CGPointEqualToPoint(_scrollView.contentOffset, offset)) { CGRect maxRect = CGRectMake( fmin(-_scrollView.contentInset.left, 0),