Skip to content

Commit 0e2fd32

Browse files
authored
fix(Fabric,Android): header subviews do not support dynamic content changes (#2910)
## Description Fixes #2714 on Android Fixes #2815 on Android See #2905 for detailed description. ## Changes Removed call to `RNSScreenStaceaderSubviewShadowNode.setSize` in corresponding component descriptor. It seems that we do not need to enforce node size from HostTree. Setting appropriate content offset is enough for pressables to function correctly (assuming that native layout **does not change size of any subview**). I currently can't come up with any scenario where this would happen. ## Test code and steps to reproduce I've tested: * [x] `Test2714` introduced in PR with iOS fixes - #2905 * [x] Pressables in header - #2466, * [x] Header title truncation - #2325 (only few cases, as the list is long there) & noticed a regression (not related to this PR, described in comment below the PR description), * [x] Insets with orientation change (Android) - #2756 * [x] #2807 (on `TestHeaderTitle` with call to `setOptions` in `useLayoutEffect`) * [x] `Test2811` - #2811 * [x] #2812 (with snippet provided in that PR description) ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes
1 parent ad24734 commit 0e2fd32

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewComponentDescriptor.h

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,9 @@ class RNSScreenStackHeaderSubviewComponentDescriptor final
2020
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
2121

2222
void adopt(ShadowNode &shadowNode) const override {
23-
#ifdef ANDROID
24-
react_native_assert(
25-
dynamic_cast<RNSScreenStackHeaderSubviewShadowNode *>(&shadowNode));
26-
auto &subviewShadowNode =
27-
static_cast<RNSScreenStackHeaderSubviewShadowNode &>(shadowNode);
28-
29-
react_native_assert(
30-
dynamic_cast<YogaLayoutableShadowNode *>(&subviewShadowNode));
31-
auto &layoutableShadowNode =
32-
dynamic_cast<YogaLayoutableShadowNode &>(subviewShadowNode);
33-
34-
auto state = std::static_pointer_cast<
35-
const RNSScreenStackHeaderSubviewShadowNode::ConcreteState>(
36-
shadowNode.getState());
37-
auto stateData = state->getData();
38-
39-
if (!isSizeEmpty(stateData.frameSize)) {
40-
layoutableShadowNode.setSize(stateData.frameSize);
41-
}
42-
#endif
23+
// Note: Be very careful with calling `shadowNode.setSize` here. By doing
24+
// that, you are likely to introduce a regressions on both platforms. See:
25+
// https://github.com/software-mansion/react-native-screens/pull/2905
4326

4427
ConcreteComponentDescriptor::adopt(shadowNode);
4528
}

0 commit comments

Comments
 (0)