Skip to content

Commit 53da095

Browse files
gigobytem-bert
andauthored
[Android] Fix crash when a Text inside a detector gets an inline View (#4588)
## Description Fixes #4585 ## Test plan 1. Reproduction example from the issue [report](#4585) no longer crashes the app 2. Smoke testing this change in a large application didn't lead to a regression is any other behaviour --------- Co-authored-by: Michał <michal.bert@swmansion.com>
1 parent 0f8b2ba commit 53da095

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎packages/react-native-gesture-handler/shared/shadowNodes/react/renderer/components/rngesturehandler_codegen/RNGestureHandlerDetectorShadowNode.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <react/renderer/graphics/Transform.h>
1515

16+
#include <cstring>
1617
#include <limits>
1718

1819
namespace facebook::react {
@@ -155,6 +156,15 @@ RNGestureHandlerDetectorShadowNode::unflattenNode(
155156
std::static_pointer_cast<RNGestureHandlerDetectorShadowNode>(clonedNode);
156157

157158
clonedNodeWithProtectedAccess->traits_.set(ShadowNodeTraits::FormsView);
159+
160+
#ifdef ANDROID
161+
// Android TextView is not a ViewGroup, so a Paragraph must not form a
162+
// stacking context or its inline views get mounted into it and crash
163+
if (std::strcmp(node->getComponentName(), "Paragraph") == 0) {
164+
return clonedNode;
165+
}
166+
#endif
167+
158168
clonedNodeWithProtectedAccess->traits_.set(
159169
ShadowNodeTraits::FormsStackingContext);
160170

0 commit comments

Comments
 (0)