From 12aef32b82325ab143b6ed421f3cbf0f8be66f60 Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Tue, 30 Apr 2024 20:59:35 -0700 Subject: [PATCH] Apply padding to the text attachements (#44258) Summary: Paddings are not applied to inline views in text, this PR fixes that. Closes https://github.com/facebook/react-native/issues/42099 ## Changelog: [GENERAL] [FIXED] - Fixed padding not being applied to inline views in text Pull Request resolved: https://github.com/facebook/react-native/pull/44258 Test Plan:
A simple test case ```jsx foobar foobar ``` |iOS before|iOS after|Android before|Android after| |-|-|-|-| |Screenshot 2024-04-25 at 17 17 50|Screenshot 2024-04-25 at 17 15 56|Screenshot 2024-04-26 at 11 18 17|Screenshot 2024-04-26 at 11 17 11|
Reviewed By: christophpurrer Differential Revision: D56789213 Pulled By: NickGerleman fbshipit-source-id: 2dd0e4bf291e20b3e4c4d73f58079d1abafc3f8e --- .../react/renderer/components/text/ParagraphShadowNode.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp index 55b37890b87..8d4a9b07aec 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp @@ -243,6 +243,9 @@ void ParagraphShadowNode::layout(LayoutContext layoutContext) { dynamic_cast(*clonedShadowNode); auto attachmentFrame = measurement.attachments[i].frame; + attachmentFrame.origin.x += layoutMetrics.contentInsets.left; + attachmentFrame.origin.y += layoutMetrics.contentInsets.top; + auto attachmentSize = roundToPixel<&ceil>( attachmentFrame.size, layoutMetrics.pointScaleFactor); auto attachmentOrigin = roundToPixel<&round>(