-
Notifications
You must be signed in to change notification settings - Fork 167
fix: adjust content inset behavior for macOS #2806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ | |
| - (instancetype)initWithFrame:(CGRect)frame | ||
| { | ||
| if (self = [super initWithFrame:frame]) { | ||
| #if !TARGET_OS_OSX // [macOS] | ||
|
Check failure on line 34 in packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm
|
||
| // 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. | ||
|
|
@@ -41,7 +41,30 @@ | |
| // 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; | ||
| #endif // [macOS] | ||
| #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, | ||
| // 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; | ||
|
Check failure on line 66 in packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm
|
||
|
|
||
|
|
||
| __weak __typeof(self) weakSelf = self; | ||
| _delegateSplitter = [[RCTGenericDelegateSplitter alloc] initWithDelegateUpdateBlock:^(id delegate) { | ||
|
|
@@ -299,4 +322,4 @@ | |
| scrollView.contentSize.width > self.frame.size.width; | ||
| } | ||
|
|
||
| @end | ||
|
Check failure on line 325 in packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm
|
||
Uh oh!
There was an error while loading. Please reload this page.