fix: inappropriate text wrapping during layout calculation #1791
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In some cases, it seems there was an extra line being inserted during drop cap layout calculation on iOS, as seen below.
I spent quite a long time thinking this was an issue in the layout engine, but eventually ruled that out when I noticed that the height of one of the words going into it was double what it needed to be. When I made the layout text elements appear, I noticed one of the words was wrapping inappropriately, which was throwing off the calculations in the layout engine.
It seems that the defined width on the iOS container, which I believe was added to cancel an iOS optimisation from preventing
onLayout
from being called, was causing React Native to intermittently attempt to wrap certain words before it gave up. Removing this defined width prevents the inappropriate wrapping, and it also seems we don't need that defined width to ensureonLayout
is called.In terms of the cause of this inappropriate wrapping, I'm not entirely sure what it is, but it seems it could be connected to facebook/react-native#18258
@jmars you may well be particularly interested in this as you may know more about why the defined width was necessary in the first place.