-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
iOS: Support inline view truncation #21456
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nested text is my favorite feature! True! ❤️
If text is truncated and an inline view appears after the truncation point, the user should not see the inline view. Instead, we have a bug such that the inline view is always visible at the end of the visible text. This commit fixes this by marking the inline view as hidden if it appears after the truncation point. **Before fix** Inline view is visible even though it appears after the truncation point: ![image](https://user-images.githubusercontent.com/199935/46381972-7d39d380-c65d-11e8-8354-91f65af651e4.png) **After fix** Inline view is properly truncated: ![image](https://user-images.githubusercontent.com/199935/46381918-3ba92880-c65d-11e8-8e61-1d6a1aae2c72.png) **Test Plan** Tested that the inline view is hidden if it appears after the truncation point when `numberOfLines` is 1 and 2. Similarly, verified that the inline view is visible if it appears before the truncation point. Adam Comella Microsoft Corp.
…isHiddenDueToClipping` field
dd1552d
to
e8500ef
Compare
Generated by 🚫 dangerJS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shergin is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: If text is truncated and an inline view appears after the truncation point, the user should not see the inline view. Instead, we have a bug such that the inline view is always visible at the end of the visible text. This commit fixes this by marking the inline view as hidden if it appears after the truncation point. This appears to be a regression. React Native used to have logic similar to what this commit is adding: https://github.com/facebook/react-native/blob/1e2a924ba60001c6f0587c7561536f00b2922cbf/Libraries/Text/RCTShadowText.m#L186-L192 **Before fix** Inline view (blue square) is visible even though it appears after the truncation point: ![image](https://user-images.githubusercontent.com/199935/46382038-d3a71200-c65d-11e8-8179-2ce4aad8d010.png) The full text being rendered was: ``` <Text numberOfLines={1}> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna <View style={{width: 50, height: 50, backgroundColor: 'steelblue'}} /> </Text> ``` **After fix** Inline view is properly truncated: ![image](https://user-images.githubusercontent.com/199935/46382067-fdf8cf80-c65d-11e8-84ea-e2b71c229dae.png) **Test Plan** Tested that the inline view is hidden if it appears after the truncation point when `numberOfLines` is 1 and 2. Similarly, verified that the inline view is visible if it appears before the truncation point. **Release Notes** [IOS] [BUGFIX] [Text] - Fix case where inline view is visible even though it should have been truncated Adam Comella Microsoft Corp. Pull Request resolved: #21456 Differential Revision: D10182991 Pulled By: shergin fbshipit-source-id: a5bddddb1bb8672b61d4feaa04013a92c8224155
Summary: If text is truncated and an inline view appears after the truncation point, the user should not see the inline view. Instead, we have a bug such that the inline view is always visible at the end of the visible text. This commit fixes this by marking the inline view as hidden if it appears after the truncation point. This appears to be a regression. React Native used to have logic similar to what this commit is adding: https://github.com/facebook/react-native/blob/1e2a924ba60001c6f0587c7561536f00b2922cbf/Libraries/Text/RCTShadowText.m#L186-L192 **Before fix** Inline view (blue square) is visible even though it appears after the truncation point: ![image](https://user-images.githubusercontent.com/199935/46382038-d3a71200-c65d-11e8-8179-2ce4aad8d010.png) The full text being rendered was: ``` <Text numberOfLines={1}> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna <View style={{width: 50, height: 50, backgroundColor: 'steelblue'}} /> </Text> ``` **After fix** Inline view is properly truncated: ![image](https://user-images.githubusercontent.com/199935/46382067-fdf8cf80-c65d-11e8-84ea-e2b71c229dae.png) **Test Plan** Tested that the inline view is hidden if it appears after the truncation point when `numberOfLines` is 1 and 2. Similarly, verified that the inline view is visible if it appears before the truncation point. **Release Notes** [IOS] [BUGFIX] [Text] - Fix case where inline view is visible even though it should have been truncated Adam Comella Microsoft Corp. Pull Request resolved: facebook#21456 Differential Revision: D10182991 Pulled By: shergin fbshipit-source-id: a5bddddb1bb8672b61d4feaa04013a92c8224155
If text is truncated and an inline view appears after the truncation point, the user should not see the inline view. Instead, we have a bug such that the inline view is always visible at the end of the visible text.
This commit fixes this by marking the inline view as hidden if it appears after the truncation point.
This appears to be a regression. React Native used to have logic similar to what this commit is adding:
react-native/Libraries/Text/RCTShadowText.m
Lines 186 to 192 in 1e2a924
Before fix
Inline view (blue square) is visible even though it appears after the truncation point:
The full text being rendered was:
After fix
Inline view is properly truncated:
Test Plan
Tested that the inline view is hidden if it appears after the truncation point when
numberOfLines
is 1 and 2. Similarly, verified that the inline view is visible if it appears before the truncation point.Release Notes
[IOS] [BUGFIX] [Text] - Fix case where inline view is visible even though it should have been truncated
Adam Comella
Microsoft Corp.