Skip to content

Commit 256c84f

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 256c84f

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

ios/bottom-tabs/screen/RNSBottomTabsScreenComponentView.mm

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ @implementation RNSBottomTabsScreenComponentView {
3232

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

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

0 commit comments

Comments
 (0)