-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Apply padding to the text attachements #44258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply padding to the text attachements #44258
Conversation
Base commit: c96c893 |
First things that come to mind:
|
It seems like it, though the exact mechanism differs between Android and iOS. Both pass On iOS, the text storage with the maximum width is created and used to measure text: Lines 48 to 54 in be06fd4
On Android, the min/max size is passed to the java measure method: Lines 138 to 149 in be06fd4
Lines 511 to 519 in be06fd4
When it comes to drawing, iOS uses the content frame directly: Line 134 in be06fd4
On Android the insets are passed on to the native view as padding: react-native/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp Line 623 in be06fd4
Lines 259 to 261 in be06fd4
But in both cases, the measurement logic itself is unaware of the padding. |
Yes, and yes. Before I saw that the padding itself is not passed to the measurement I tried to access the padding in the Using |
@NickGerleman Friendly ping in case you missed the response. |
@j-piasecki yeah I think the only change needed here is just moving to content insets |
@NickGerleman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@NickGerleman merged this pull request in 12aef32. |
This pull request was successfully merged by @j-piasecki in 12aef32. When will my fix make it into a release? | How to file a pick request? |
Summary: Paddings are not applied to inline views in text, this PR fixes that. Closes facebook#42099 ## Changelog: [GENERAL] [FIXED] - Fixed padding not being applied to inline views in text Pull Request resolved: facebook#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
Summary: Paddings are not applied to inline views in text, this PR fixes that. Closes facebook#42099 ## Changelog: [GENERAL] [FIXED] - Fixed padding not being applied to inline views in text Pull Request resolved: facebook#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
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
Test Plan:
A simple test case