diff --git a/cpp/TransformerTextInputDecoratorViewShadowNode.cpp b/cpp/TransformerTextInputDecoratorViewShadowNode.cpp index aa217cf..f912d87 100644 --- a/cpp/TransformerTextInputDecoratorViewShadowNode.cpp +++ b/cpp/TransformerTextInputDecoratorViewShadowNode.cpp @@ -1,5 +1,7 @@ #include "TransformerTextInputDecoratorViewShadowNode.h" +#include + namespace facebook::react { const char TransformerTextInputDecoratorViewComponentName[] = @@ -15,7 +17,28 @@ void TransformerTextInputDecoratorViewShadowNode::initialize() { void TransformerTextInputDecoratorViewShadowNode::layout( LayoutContext layoutContext) { - ConcreteViewShadowNode::layout(layoutContext); + YogaLayoutableShadowNode::layout(layoutContext); + + // Nodes with display: contents are skipped during Yoga layout and end up + // with zero-sized metrics. To get a proper host view (so input and + // accessibility wiring works on Android), copy the child's Yoga-computed + // metrics onto the decorator and zero out the child's origin since it is + // now relative to the decorator. + const auto &children = getChildren(); + react_native_assert( + children.size() == 1 && + "TransformerTextInputDecoratorView didn't receive exactly one child"); + + auto child = + std::static_pointer_cast(children[0]); + child->ensureUnsealed(); + auto mutableChild = std::const_pointer_cast(child); + + auto childMetrics = child->getLayoutMetrics(); + setLayoutMetrics(childMetrics); + + childMetrics.frame.origin = Point{}; + mutableChild->setLayoutMetrics(childMetrics); } } // namespace facebook::react