Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions apps/src/tests/Test3425.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { useState } from 'react';
import { Button, View } from 'react-native';
import Colors from '../shared/styling/Colors';
import { TestBottomTabs } from '.';

export default function App() {
const [index, setIndex] = useState(0);
return (
<View
style={{
flex: 1,
paddingHorizontal: 20,
paddingVertical: 100,
backgroundColor: Colors.BlueLight40,
}}>
{index === 0 ? (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}}>
<Button title="Go to Bottom Tabs" onPress={() => setIndex(1)} />
</View>
) : (
<TestBottomTabs />
)}
</View>
);
}
1 change: 1 addition & 0 deletions apps/src/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export { default as Test3342 } from './Test3342';
export { default as Test3346 } from './Test3346';
export { default as Test3369 } from './Test3369';
export { default as Test3379 } from './Test3379';
export { default as Test3425 } from './Test3425';
export { default as TestScreenAnimation } from './TestScreenAnimation';
export { default as TestScreenAnimationV5 } from './TestScreenAnimationV5';
export { default as TestHeader } from './TestHeader';
Expand Down
18 changes: 18 additions & 0 deletions ios/bottom-tabs/host/RNSBottomTabsHostComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,24 @@ - (void)reactAddControllerToClosestParent:(UIViewController *)controller
}
}

#if RCT_NEW_ARCH_ENABLED

// On Fabric, when tabs are rendered dynamically, tab screens receive incorrect frame from UIKit layout
// (frame matches full window size instead of the size of the host). To mitigate this, we override
// `layoutSubviews` and assign correct frame ourselves.
// TODO: investigate why we receive incorrect frame, fix and remove this workaround
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include an issue number for the TODO ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is not a workaround anymore and layout constraints should stay so no need to mark them for removal. I will keep the ticket for research because it might be useful to know why this happens (but it's not crucial).

- (void)layoutSubviews
{
RCTAssert(
self.subviews.count == 1,
@"[RNScreens] Unexpected number of subviews in RNSBottomTabsHostComponentView. Expected 1, actual: %lu.",
static_cast<unsigned long>(self.subviews.count));

[self.subviews[0] setFrame:self.bounds];
}

#endif // RCT_NEW_ARCH_ENABLED

#pragma mark - RNSScreenContainerDelegate

- (void)updateContainer
Expand Down
Loading