mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-08 22:42:05 +08:00
RCTVirtualText wasn't clickable in certain cases
Summary: Text in Nodes is squashed into a single DrawCommand for drawing a Boring or StaticLayout. Touch is handled using a TextNodeRegion subclass of NodeRegion that knows how to identify pieces of text inside of the DrawCommand based on spans in the text. However, we only use a TextNodeRegion on the second call for updateNodeRegion for an RCTText. If there is only one call, the NodeRegion will just be a normal one. This patch ensures that the NodeRegion for an RCTText is always a TextNodeRegion, allowing for null Layouts that are set when the DrawCommand is made. Reviewed By: astreet Differential Revision: D3291682
This commit is contained in:
@@ -179,6 +179,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean updateNodeRegion = false;
|
||||
if (mDrawCommand == null) {
|
||||
// Layout was not created during the measure pass, must be Boring, create it now
|
||||
mDrawCommand = new DrawTextLayout(new BoringLayout(
|
||||
@@ -190,6 +191,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
mSpacingAdd,
|
||||
mBoringLayoutMetrics,
|
||||
INCLUDE_PADDING));
|
||||
updateNodeRegion = true;
|
||||
}
|
||||
|
||||
Spacing padding = getPadding();
|
||||
@@ -212,6 +214,13 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
clipBottom);
|
||||
stateBuilder.addDrawCommand(mDrawCommand);
|
||||
|
||||
if (updateNodeRegion) {
|
||||
NodeRegion nodeRegion = getNodeRegion();
|
||||
if (nodeRegion instanceof TextNodeRegion) {
|
||||
((TextNodeRegion) nodeRegion).setLayout(mDrawCommand.getLayout());
|
||||
}
|
||||
}
|
||||
|
||||
performCollectAttachDetachListeners(stateBuilder);
|
||||
}
|
||||
|
||||
@@ -240,12 +249,16 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
float right,
|
||||
float bottom,
|
||||
boolean isVirtual) {
|
||||
|
||||
NodeRegion nodeRegion = getNodeRegion();
|
||||
if (mDrawCommand == null) {
|
||||
super.updateNodeRegion(left, top, right, bottom, isVirtual);
|
||||
if (nodeRegion.mLeft != left || nodeRegion.mTop != top || nodeRegion.mRight != right ||
|
||||
nodeRegion.mBottom != bottom || nodeRegion.mIsVirtual != isVirtual) {
|
||||
setNodeRegion(new TextNodeRegion(left, top, right, bottom, getReactTag(), isVirtual, null));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NodeRegion nodeRegion = getNodeRegion();
|
||||
Layout layout = null;
|
||||
|
||||
if (nodeRegion instanceof TextNodeRegion) {
|
||||
|
||||
Reference in New Issue
Block a user