Skip to content

Commit

Permalink
fix: vertical scroll views are detected as horizontals (#46836)
Browse files Browse the repository at this point in the history
Summary:
There is a numerical issue that causes vertical scroll view to be considered as the horizontal one and leads to problems described [here](#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 #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: #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
  • Loading branch information
coado authored and facebook-github-bot committed Oct 10, 2024
1 parent 46a9711 commit ab8f3ff
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#import "RCTEnhancedScrollView.h"
#import <React/RCTUtils.h>
#import <react/utils/FloatComparison.h>

@interface RCTEnhancedScrollView () <UIScrollViewDelegate>
@end
Expand Down Expand Up @@ -261,7 +262,8 @@ - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView

- (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

0 comments on commit ab8f3ff

Please sign in to comment.