Skip to content

Commit 2b99204

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Fix culling of views having no layout breaking embedded Text event handlers (#53466)
Summary: Pull Request resolved: #53466 This is a follow-up on D80631997. When enabling View Culling on Android, wrapped Text components would lead to event handlers set by the inner Text component not being set on the attributed string. ``` <Paragraph> <Text onPress={myHandler}> <- This handler is not set <RawText/> </Text> </Paragraph> ``` This was due to the inner Text component having no size and hence being culled by the View Culling algorithm. This diff disables view culling for views having no size, since no layout means no valid decision can be made as to the visibility of the component within the viewport. It also removes the change made by D80631997. This means Text views with a layout size set can be culled again. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D81044841 fbshipit-source-id: e9b01dcb8030b271876329b9b2c5bda36ba2b87a
1 parent a4bf14a commit 2b99204

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

packages/react-native/ReactCommon/react/renderer/components/text/TextShadowNode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class TextShadowNode : public ConcreteShadowNode<
3131
auto traits = ConcreteShadowNode::BaseTraits();
3232
#ifdef ANDROID
3333
traits.set(ShadowNodeTraits::Trait::FormsView);
34-
traits.set(ShadowNodeTraits::Trait::Unstable_uncullableView);
3534
#endif
3635
return traits;
3736
}

packages/react-native/ReactCommon/react/renderer/mounting/internal/sliceChildShadowNodeViewPairs.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,16 @@ static void sliceChildShadowNodeViewPairsRecursively(
8080
overflowInsetFrame =
8181
overflowInsetFrame * layoutableShadowNode->getTransform();
8282
}
83+
84+
// Embedded Text components can have an empty layout, while these still
85+
// need to be mounted to set the correct react tags on the text
86+
// fragments. These should not be culled.
87+
auto hasLayout = overflowInsetFrame.size.width > 0 ||
88+
overflowInsetFrame.size.height > 0;
89+
8390
auto doesIntersect =
8491
Rect::intersect(cullingContext.frame, overflowInsetFrame) != Rect{};
85-
if (!doesIntersect) {
92+
if (hasLayout && !doesIntersect) {
8693
continue; // Culling.
8794
}
8895
}

0 commit comments

Comments
 (0)