Skip to content
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

Fix contentInsetAdjustmentBehavior set to automatic on ScrollView in the new architecture #34217

Closed
wants to merge 9 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ @implementation RCTScrollViewComponentView {
BOOL _shouldUpdateContentInsetAdjustmentBehavior;

CGPoint _contentOffsetWhenClipped;
CGRect _oldFrame;
}

+ (RCTScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(UIView *)view
Expand Down Expand Up @@ -130,6 +131,7 @@ - (instancetype)initWithFrame:(CGRect)frame
[self.scrollViewDelegateSplitter addDelegate:self];

_scrollEventThrottle = INFINITY;
_oldFrame = CGRectNull;
}

return self;
Expand Down Expand Up @@ -178,6 +180,10 @@ - (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
if (!CGRectEqualToRect(_oldFrame, CGRectNull)) {
[self setFrame:_oldFrame];
_oldFrame = CGRectNull;
}
const auto &oldScrollViewProps = *std::static_pointer_cast<const ScrollViewProps>(_props);
const auto &newScrollViewProps = *std::static_pointer_cast<const ScrollViewProps>(props);

Expand Down Expand Up @@ -401,6 +407,8 @@ - (void)prepareForRecycle
_shouldUpdateContentInsetAdjustmentBehavior = YES;
_state.reset();
_isUserTriggeredScrolling = NO;
_oldFrame = self.frame;
[self setFrame:CGRectZero];
[super prepareForRecycle];
}

Expand Down