From 61a834e5f4e1762c8efd48013ef1e57090279478 Mon Sep 17 00:00:00 2001 From: eadron Date: Thu, 15 Jan 2026 11:04:00 -0800 Subject: [PATCH 1/3] Adjust content inset behavior for macOS Fix content inset adjustments for macOS ScrollView. --- .../ComponentViews/ScrollView/RCTEnhancedScrollView.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm index a7bc9c5b4425..949daf661f41 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm @@ -41,6 +41,12 @@ - (instancetype)initWithFrame:(CGRect)frame // because this attribute affects a position of vertical scrollbar; we don't want this // scrollbar flip because we also flip it with whole `UIScrollView` flip. self.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight; +#else // [macOS + // Similar to iOS's contentInsetAdjustmentBehavior fix + // For example: When using NSWindowStyleMaskFullSizeContentView (hidden title bar) and ScrollView as root, + // NSScrollView.automaticallyAdjustsContentInsets (default YES) adds contentInset.top to push content below the toolbar. + // However, React Native doesn't know about this native contentInset adjustments,causing some caltulation issues + self.automaticallyAdjustsContentInsets = NO; #endif // [macOS] __weak __typeof(self) weakSelf = self; From fc45deeef2fee33a5845812723b093ed3ce96853 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Sun, 22 Mar 2026 22:59:13 -0500 Subject: [PATCH 2/3] Apply suggestion from @Saadnajmi --- .../ScrollView/RCTEnhancedScrollView.mm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm index 949daf661f41..7b6861440d40 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm @@ -47,7 +47,24 @@ - (instancetype)initWithFrame:(CGRect)frame // NSScrollView.automaticallyAdjustsContentInsets (default YES) adds contentInset.top to push content below the toolbar. // However, React Native doesn't know about this native contentInset adjustments,causing some caltulation issues self.automaticallyAdjustsContentInsets = NO; -#endif // [macOS] +#if !TARGET_OS_OSX // [macOS] +// We set the default behavior to "never" so that iOS +// doesn't do weird things to UIScrollView insets automatically +// and keeps it as an opt-in behavior. +self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; +#else // [macOS + // Similar to iOS's contentInsetAdjustmentBehavior fix + // For example: When using NSWindowStyleMaskFullSizeContentView (hidden title bar) and ScrollView as root, + // NSScrollView.automaticallyAdjustsContentInsets (default YES) adds contentInset.top to push content below the toolbar. + // However, React Native doesn't know about this native contentInset adjustments,causing some caltulation issues + self.automaticallyAdjustsContentInsets = NO; +#endif // macOS] + +// We intentionally force `UIScrollView`s `semanticContentAttribute` to `LTR` here +// because this attribute affects a position of vertical scrollbar; we don't want this +// scrollbar flip because we also flip it with whole `UIScrollView` flip. +self.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight; + __weak __typeof(self) weakSelf = self; _delegateSplitter = [[RCTGenericDelegateSplitter alloc] initWithDelegateUpdateBlock:^(id delegate) { From da19380f345f743ede4ca8178ee5adc73a174f51 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Mon, 23 Mar 2026 10:33:15 -0500 Subject: [PATCH 3/3] Apply suggestion from @Saadnajmi --- .../ScrollView/RCTEnhancedScrollView.mm | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm index 7b6861440d40..2489b3eb1751 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm @@ -41,17 +41,6 @@ - (instancetype)initWithFrame:(CGRect)frame // because this attribute affects a position of vertical scrollbar; we don't want this // scrollbar flip because we also flip it with whole `UIScrollView` flip. self.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight; -#else // [macOS - // Similar to iOS's contentInsetAdjustmentBehavior fix - // For example: When using NSWindowStyleMaskFullSizeContentView (hidden title bar) and ScrollView as root, - // NSScrollView.automaticallyAdjustsContentInsets (default YES) adds contentInset.top to push content below the toolbar. - // However, React Native doesn't know about this native contentInset adjustments,causing some caltulation issues - self.automaticallyAdjustsContentInsets = NO; -#if !TARGET_OS_OSX // [macOS] -// We set the default behavior to "never" so that iOS -// doesn't do weird things to UIScrollView insets automatically -// and keeps it as an opt-in behavior. -self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; #else // [macOS // Similar to iOS's contentInsetAdjustmentBehavior fix // For example: When using NSWindowStyleMaskFullSizeContentView (hidden title bar) and ScrollView as root, @@ -60,12 +49,6 @@ - (instancetype)initWithFrame:(CGRect)frame self.automaticallyAdjustsContentInsets = NO; #endif // macOS] -// We intentionally force `UIScrollView`s `semanticContentAttribute` to `LTR` here -// because this attribute affects a position of vertical scrollbar; we don't want this -// scrollbar flip because we also flip it with whole `UIScrollView` flip. -self.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight; - - __weak __typeof(self) weakSelf = self; _delegateSplitter = [[RCTGenericDelegateSplitter alloc] initWithDelegateUpdateBlock:^(id delegate) { [weakSelf setPrivateDelegate:delegate];