Skip to content

Commit fc45dee

Browse files
authored
Apply suggestion from @Saadnajmi
1 parent 61a834e commit fc45dee

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,24 @@ - (instancetype)initWithFrame:(CGRect)frame
4747
// NSScrollView.automaticallyAdjustsContentInsets (default YES) adds contentInset.top to push content below the toolbar.
4848
// However, React Native doesn't know about this native contentInset adjustments,causing some caltulation issues
4949
self.automaticallyAdjustsContentInsets = NO;
50-
#endif // [macOS]
50+
#if !TARGET_OS_OSX // [macOS]
51+
// We set the default behavior to "never" so that iOS
52+
// doesn't do weird things to UIScrollView insets automatically
53+
// and keeps it as an opt-in behavior.
54+
self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
55+
#else // [macOS
56+
// Similar to iOS's contentInsetAdjustmentBehavior fix
57+
// For example: When using NSWindowStyleMaskFullSizeContentView (hidden title bar) and ScrollView as root,
58+
// NSScrollView.automaticallyAdjustsContentInsets (default YES) adds contentInset.top to push content below the toolbar.
59+
// However, React Native doesn't know about this native contentInset adjustments,causing some caltulation issues
60+
self.automaticallyAdjustsContentInsets = NO;
61+
#endif // macOS]
62+
63+
// We intentionally force `UIScrollView`s `semanticContentAttribute` to `LTR` here
64+
// because this attribute affects a position of vertical scrollbar; we don't want this
65+
// scrollbar flip because we also flip it with whole `UIScrollView` flip.
66+
self.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
67+
5168

5269
__weak __typeof(self) weakSelf = self;
5370
_delegateSplitter = [[RCTGenericDelegateSplitter alloc] initWithDelegateUpdateBlock:^(id delegate) {

0 commit comments

Comments
 (0)