TextView is not correctly sized if it is styled with maxWidth
The text in the TextView is being partially displayed if its stylesheet contains maxWidth property.
Screenshot with maxWidth: 300:

Screenshot without using maxWidth:

Minimal code snippet:
import React, { Component } from 'react';
import { AppRegistry, View, Text, StyleSheet } from 'react-native';
import Dimensions from 'Dimensions';
export default class Message extends Component {
constructor(props) {
super(props);
}
render() {
return (
<Text style={ styles.bubble }>{ this.props.sender }: { this.props.text }</Text>
);
}
}
const styles = StyleSheet.create({
bubble: {
maxWidth: 300, // the bug occurs only when maxWidth is present in the styles
marginBottom: 10,
padding: 10,
backgroundColor: '#0086EF',
}
});
Works correct on Android, the problem occurs only in iOS (EDIT 09.08.2016: after testing it again with Android I can reproduce the problem there also, so it affects iOS and Android). react-native: 0.31.0
I just came across something that looks quite similar. I can repro on Android, but not 100% about iOS yet.
Minimal RN Play example that shows the problem on android: https://rnplay.org/apps/aSc6cw
Top text line has maxWidth: 300 applied and shows the text getting cut off.

@emilsjolander are you the best person to look into this issue or should it go to someone more familiar with the Android side of RN?
Given how it repros differently on ios and android I would assume there is something funky with the text measurement logic. Someone on RN is best to look at this. Happy to help if this turns out to be a layout issue and not a measurement issue.
@wli what version did you repro this on? Has the behavior changed at all between 0.31 and 0.37?
What would you expect the rendering to look like when maxWidth is used?
@hramos This was on 0.33.0, haven't had a chance to repro on the latest version yet, but I may be able to check on 0.36 if rnplay updates to exponent SDK11.
I expect the text to wrap onto a second line, and effectively leave a right margin.
@hramos This behavior is still present on 0.37
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!
If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
- Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
- If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
- Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.