Skip to content
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

Fix updating RCTText with new text of the same size #989

Closed
wants to merge 1 commit into from

Conversation

sophiebits
Copy link
Contributor

Fixes #979.

Previously, a Text whose width is determined automatically (as opposed to set by a container) would position the text incorrectly after an update to the text if the text's width did not change (i.e., when changing only digits in a font with tabular numbers).

Every time RCTShadowText's RCTMeasure runs, it sets the text container's size to be the maximum allowed size for the text. When RCTText's drawRect is called later, it relied on layoutSubviews having been called to set the text container's size back to the proper width. But if RCTMeasure returned the same dimensions as last time, then RCTText's frame wasn't reset and so layoutSubviews was never re-called. With this change, we set the textContainer's size each time we draw the text.

We could also fix this by using a different NSTextContainer instance in RCTMeasure. Not sure what the pros and cons of that are.

Fixes facebook#979.

Previously, a Text whose width is determined automatically (as opposed
to set by a container) would position the text incorrectly after an
update to the text *if* the text's width did not change (i.e., when
changing only digits in a font with tabular numbers).

Every time RCTShadowText's RCTMeasure runs, it sets the text container's
size to be the maximum allowed size for the text. When RCTText's
drawRect is called later, it relied on layoutSubviews having been called
to set the text container's size back to the proper width. But if
RCTMeasure returned the same dimensions as last time, then RCTText's
frame wasn't reset and so layoutSubviews was never re-called. With this
change, we set the textContainer's size each time we draw the text.

We could also fix this by using a different NSTextContainer instance in
RCTMeasure. Not sure what the pros and cons of that are.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 23, 2015
ayushjainrksh pushed a commit to MLH-Fellowship/react-native that referenced this pull request Jul 2, 2020
* update docs for appstate module

* Update appstate.md
acoates-ms pushed a commit to acoates-ms/react-native that referenced this pull request Jan 26, 2022
…ok#989)

* Add --autogenerateVersionNumber option to bump-oss-version.js

* Add missing comma to patch file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text layout bug on update with non-left textAlign
3 participants