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.

Text component adds a linebreak when string content is equal to width of component

See original GitHub issue

React Native version:

React Native Environment Info:
    System:
      OS: macOS 10.15.1
      CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 164.17 MB / 16.00 GB
      Shell: 3.0.2 - /usr/local/bin/fish
    Binaries:
      Node: 12.4.0 - /usr/local/bin/node
      Yarn: yarn install v0.21.3
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.46s. - /usr/local/bin/yarn
      npm: 6.11.3 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
      Android SDK:
        API Levels: 26, 27, 28
        Build Tools: 27.0.3, 28.0.0, 28.0.3
        System Images: android-26 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.5 AI-191.8026.42.35.5900203
      Xcode: 11.2.1/11B53 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz => 0.59.8
    npmGlobalPackages:
      eslint-plugin-react-native: 3.2.1
      react-native-cli: 2.0.1

Steps To Reproduce

  1. Add a Text component anywhere in project (add another component underneath it or use a border - needed to see the issue)
  2. Add some text to get it to reach the exact width of the Text component - this may take a few attempts as not all characters have the same width and may require using some punctuation as well
  3. The text will introduce an unwanted linebreak without any characters moving with it, creating a new blank line with no text

Describe what you expected to happen: Some text should either wrap to the new line or a new line should not be created.

Actual Behavior On both iOS & Android, when the length of the text string is the width of the Text component, it adds a linebreak, creating extra space below text elements.

My guess is that there’s some sort of improper rounding happening with float density pixels or something.

Snack, code example, screenshot, or link to a repository: https://snack.expo.io/@shamilot/text-early-line-wrap

Screen Shot 2019-11-08 at 2 54 59 PM Screen Shot 2019-11-08 at 2 54 28 PM

+1 / related: #15893 #24674 #24977

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
shamilovtimcommented, Nov 18, 2019

Is there any way to get some eyes on this? It’s a major bug and it has been largely ignored.

0reactions
stale[bot]commented, May 23, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Text component adds a linebreak when string content is equal ...
On both iOS & Android, when the length of the text string is the width of the Text component, it adds a linebreak....
Read more >
How can I insert a line break into a <Text> component in ...
There are two main solutions for this. Method 2: Add the line break it in the string literals, like below. For more information,...
Read more >
word-break - CSS: Cascading Style Sheets - MDN Web Docs
The word-break CSS property sets whether line breaks appear wherever the text would otherwise overflow its content box.
Read more >
Injecting a Line Break | CSS-Tricks
I had a little situation where I had a header with a span in it, and I wanted to make sure to put...
Read more >
Label - .NET MAUI | Microsoft Learn
NET MAUI) Label displays single-line and multi-line text. Text displayed by a Label can be colored, spaced, and can have text decorations.
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