fix: vertical scroll views are detected as horizontals (#46836)

Summary:
There is a numerical issue that causes vertical scroll view to be considered as the horizontal one and leads to problems described [here](https://github.com/facebook/react-native/issues/46592). The problem is no longer visible after checking if the scroll view is horizontal with float equality.

~~I am not sure if it also happens on Android, so I am leaving it as a draft for now.~~

Fixes https://github.com/facebook/react-native/issues/46592

## Changelog:

[IOS] [FIXED] - check if scroll view is horizontal with float equality.

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[IOS] [FIXED] - fixed scroll view

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/46836

Test Plan: Tested on the repro provided in the above issue.

Reviewed By: rshest

Differential Revision: D64114476

Pulled By: cortinico

fbshipit-source-id: a5048e1403c4bb675d32928937d6411cfb12fd51
This commit is contained in:
Dawid
2024-10-10 06:37:28 -07:00
committed by Facebook GitHub Bot
parent 46a9711454
commit ab8f3ff3e9
@@ -7,6 +7,7 @@
#import "RCTEnhancedScrollView.h"
#import <React/RCTUtils.h>
#import <react/utils/FloatComparison.h>
@interface RCTEnhancedScrollView () <UIScrollViewDelegate>
@end
@@ -261,7 +262,8 @@
- (BOOL)isHorizontal:(UIScrollView *)scrollView
{
return scrollView.contentSize.width > self.frame.size.width;
return !facebook::react::floatEquality(scrollView.contentSize.width, self.frame.size.width) &&
scrollView.contentSize.width > self.frame.size.width;
}
@end