Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion cpp/TransformerTextInputDecoratorViewShadowNode.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "TransformerTextInputDecoratorViewShadowNode.h"

#include <react/debug/react_native_assert.h>

namespace facebook::react {

const char TransformerTextInputDecoratorViewComponentName[] =
Expand All @@ -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<const YogaLayoutableShadowNode>(children[0]);
child->ensureUnsealed();
auto mutableChild = std::const_pointer_cast<YogaLayoutableShadowNode>(child);

auto childMetrics = child->getLayoutMetrics();
setLayoutMetrics(childMetrics);

childMetrics.frame.origin = Point{};
mutableChild->setLayoutMetrics(childMetrics);
}

} // namespace facebook::react
Loading