Skip to content

Commit 6ee00bf

Browse files
Ubaxclaude
andcommitted
fix(iOS, Tabs): defer scroll view behavior override until props are set
In Fabric, the mutation order for newly created views is Create → Insert → Update, meaning mountChildComponentView fires before updateProps. This caused overrideScrollViewContentInsetAdjustmentBehavior to use its default value (YES) instead of the JS-provided value. Defer the override call when props haven't been set yet and apply it in updateProps once the prop value is known. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9bfc35c commit 6ee00bf

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ios/bottom-tabs/screen/RNSBottomTabsScreenComponentView.mm

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ @implementation RNSBottomTabsScreenComponentView {
3232

3333
// We need this information to warn users about dynamic changes to behavior being currently unsupported.
3434
BOOL _isOverrideScrollViewContentInsetAdjustmentBehaviorSet;
35+
// Tracks that the first child was mounted before props were set.
36+
// The pending override will be applied once updateProps runs.
37+
BOOL _needsScrollViewBehaviorOverride;
3538
#if !RCT_NEW_ARCH_ENABLED
3639
BOOL _tabItemNeedsAppearanceUpdate;
3740
BOOL _tabScreenOrientationNeedsUpdate;
@@ -372,6 +375,12 @@ - (void)updateProps:(const facebook::react::Props::Shared &)props
372375
// enabling us to warn users that dynamic changes are not supported.
373376
_isOverrideScrollViewContentInsetAdjustmentBehaviorSet = YES;
374377

378+
// Apply deferred scroll view override if a child was mounted before props arrived
379+
if (_needsScrollViewBehaviorOverride) {
380+
[self overrideScrollViewBehaviorInFirstDescendantChainIfNeeded];
381+
_needsScrollViewBehaviorOverride = NO;
382+
}
383+
375384
if (newComponentProps.systemItem != oldComponentProps.systemItem) {
376385
_systemItem = rnscreens::conversion::RNSBottomTabsScreenSystemItemFromReactRNSBottomTabsScreenSystemItem(
377386
newComponentProps.systemItem);
@@ -465,7 +474,13 @@ - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompone
465474
// overrideScrollViewBehavior and updateContentScrollViewEdgeEffects use first descendant chain
466475
// from screen to find ScrollView, that's why we're only interested in child mounted at index 0.
467476
if (index == 0) {
468-
[self overrideScrollViewBehaviorInFirstDescendantChainIfNeeded];
477+
// If the props were not set before the first child was mounted,
478+
// we defer the override behavior application until props are set.
479+
if (_isOverrideScrollViewContentInsetAdjustmentBehaviorSet) {
480+
[self overrideScrollViewBehaviorInFirstDescendantChainIfNeeded];
481+
} else {
482+
_needsScrollViewBehaviorOverride = YES;
483+
}
469484
[self updateContentScrollViewEdgeEffectsIfExists];
470485
}
471486
}

0 commit comments

Comments
 (0)