Skip to content

Commit

Permalink
Fix contentInsetAdjustmentBehavior set to automatic on ScrollView in …
Browse files Browse the repository at this point in the history
…the new architecture (facebook#34217) (microsoft#1484)

Summary:
Fixes facebook#34165 and [Large title fails](reactwg/react-native-new-architecture#43) on the new React Native architecture.

There are problems with setting `contentInsetAdjustmentBehavior` to `automatic` on the `ScrollView` component in the new React Native architecture. The `automatic` setting matters to navigation libraries (like [my Navigation router](https://github.com/grahammendick/navigation)) because it stops the `ScrollView` from overlapping the `UINavigationBar`. The setting also powers important native features like large titles and search bars on iOS.

The `automatic` setting works fine on the old architecture. It doesn’t work on the new architecture because React Native is recycling views. In facebook#34165 and [Large title fails](reactwg/react-native-new-architecture#43) there are videos comparing the setting in the old and the new architecture.

## Changelog

[iOS] [Fixed] - Fix `contentInsetAdjustmentBehavior` set to `automatic` on `ScrollView` in the new architecture

Pull Request resolved: facebook#34217

Test Plan:
I checked the fix in both the repros in facebook#34165 and [Large title fails](reactwg/react-native-new-architecture#43). Here is a video of the fix running with large titles in the new architecture.

https://user-images.githubusercontent.com/1761227/179612188-162b896b-82c5-45de-bb5a-ba80f452fbee.mov

Reviewed By: sammy-SC

Differential Revision: D37952506

Pulled By: cipolleschi

fbshipit-source-id: 6cff6c85aa33b579405fe34a9e36c8630f4c24bd

Co-authored-by: Graham Mendick <[email protected]>
  • Loading branch information
2 people authored and Shawn Dempsey committed Mar 10, 2023
1 parent e5025f4 commit 375af1e
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ - (void)prepareForRecycle
_shouldUpdateContentInsetAdjustmentBehavior = YES;
_state.reset();
_isUserTriggeredScrolling = NO;
CGRect oldFrame = self.frame;
self.frame = CGRectZero;
self.frame = oldFrame;
[super prepareForRecycle];
}

Expand Down

0 comments on commit 375af1e

Please sign in to comment.