Skip to content

Commit 12aef32

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Apply padding to the text attachements (#44258)
Summary: Paddings are not applied to inline views in text, this PR fixes that. Closes #42099 ## Changelog: [GENERAL] [FIXED] - Fixed padding not being applied to inline views in text Pull Request resolved: #44258 Test Plan: <details> <summary>A simple test case</summary> ```jsx <Text style={{paddingHorizontal: 40, paddingVertical: 40, backgroundColor: 'green', width: 300 }}> <View style={{backgroundColor: 'red', width: 50, height: 50}} /> foobar foobar <View style={{backgroundColor: 'red', width: 50, height: 50}} /> </Text> ``` |iOS before|iOS after|Android before|Android after| |-|-|-|-| |<img width="502" alt="Screenshot 2024-04-25 at 17 17 50" src="https://github.com/facebook/react-native/assets/21055725/e6981de0-6714-4bb0-a006-547b30374b8a">|<img width="546" alt="Screenshot 2024-04-25 at 17 15 56" src="https://github.com/facebook/react-native/assets/21055725/51e8458b-ad4e-4755-865c-664414bfee55">|<img width="457" alt="Screenshot 2024-04-26 at 11 18 17" src="https://github.com/facebook/react-native/assets/21055725/ac351eff-6d24-40a0-bf7e-0cf3782e9368">|<img width="457" alt="Screenshot 2024-04-26 at 11 17 11" src="https://github.com/facebook/react-native/assets/21055725/3284a79a-157d-43ea-b080-849520e2ee7d">| </details> Reviewed By: christophpurrer Differential Revision: D56789213 Pulled By: NickGerleman fbshipit-source-id: 2dd0e4bf291e20b3e4c4d73f58079d1abafc3f8e
1 parent 639d890 commit 12aef32

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ void ParagraphShadowNode::layout(LayoutContext layoutContext) {
243243
dynamic_cast<LayoutableShadowNode&>(*clonedShadowNode);
244244

245245
auto attachmentFrame = measurement.attachments[i].frame;
246+
attachmentFrame.origin.x += layoutMetrics.contentInsets.left;
247+
attachmentFrame.origin.y += layoutMetrics.contentInsets.top;
248+
246249
auto attachmentSize = roundToPixel<&ceil>(
247250
attachmentFrame.size, layoutMetrics.pointScaleFactor);
248251
auto attachmentOrigin = roundToPixel<&round>(

0 commit comments

Comments
 (0)