question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextView is not correctly sized if it is styled with maxWidth

See original GitHub issue

The text in the TextView is being partially displayed if its stylesheet contains maxWidth property.

Screenshot with maxWidth: 300: screen shot 2016-08-08 at 5 15 12 pm

Screenshot without using maxWidth: screen shot 2016-08-08 at 5 15 49 pm

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
wlicommented, Oct 25, 2016

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.

overflow-both

0reactions
hramoscommented, Jul 21, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto Scale TextView Text to Fit within Bounds - Stack Overflow
I have got an edittext and textview in my layout. The textview is fixed height and width. When the user starts to type...
Read more >
TextView - Android Developers
To customize the appearance of TextView, see Styles and Themes. ... android:autoSizeStepGranularity, Specify the auto-size step size if autoSizeTextType is ...
Read more >
Frame Behaviors with SwiftUI
This animation shows the difference between using fixedSize or leaving it unspecified. When we set the size as fixed, the Text view can...
Read more >
text-size-adjust - CSS: Cascading Style Sheets - MDN Web Docs
When an element containing text uses 100% of the screen's width, the algorithm increases its text size, but without modifying the layout.
Read more >
Android - TextView Control - Tutorialspoint
A TextView displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found