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

Text numberOfLines={2} and ellipsizeMode="middle" breaks on Android #19117

Closed
2 of 3 tasks
Daniel-J-Fisher opened this issue May 3, 2018 · 10 comments
Closed
2 of 3 tasks
Labels
Bug Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@Daniel-J-Fisher
Copy link

Line restriction with ellipsizeMode set in a Text componenet fails to preform any truncation on Android when numberOfLines={2} is set.

This fails: <Text numberOfLines={2} ellipsizeMode="middle" >Some long text • 10</Text>
This works: <Text numberOfLines={1} ellipsizeMode="middle" >Some long text • 10</Text>
Both of the above snippets work as expected on iOS.

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 7.0.0
Yarn: Not Found
npm: 3.10.8
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.53.0 => 0.53.0

Steps to Reproduce

On Android, combination of numberOfLines={2} and ellipsizeMode="middle" on a Text component fails to truncate the text and no ellipses are visible. When I remove ellipsizeMode it defaults to tail and it truncates the text without issue.

Code Snippet

//...
<Text 
  style={styles.text_name}
  numberOfLines={2}
  ellipsizeMode="middle"
>
  {`${this.props.listItem.name}${this.props.listItem.quantity}`}
</Text>
//...
const styles = StyleSheet.create({
  //...
  text_name: {
    color: ColorPalette.GREY.BLACK,
    fontSize: 18,
    fontFamily: fonts.proxima.semibold
  },
  //...
});

Check out my Snack reproducing this: FAILING WITH 2 LINES
Here's a Snack of it working with one line: WORKING WITH 1 LINE

Expected Behavior

I expect Android should have the same functionality as iOS

Correct iOS Screenshot
screen shot 2018-05-03 at 2 25 54 pm

Actual Behavior

I have been working on this within my app and below is a screenshot of the section of my app where this is used.

Incorrect Android Screenshot
screen shot 2018-05-03 at 2 26 04 pm

Extra Info

The reason I need ellipsizeMode="middle" is because I have a title and a number that I append to the title and want to always ensure that the number at the end is shown.

I have read through many of the issues about numberOfLines on this repo and I have not found anything that proposed a solution.

Any ideas?

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.55?

Thank you for your contributions.

@Daniel-J-Fisher
Copy link
Author

The Snack examples I posted reproduce this issue on the latest release.

@react-native-bot react-native-bot added the Ran Commands One of our bots successfully processed a command. label Jul 16, 2018
@stale
Copy link

stale bot commented Oct 14, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 14, 2018
@geminiyellow
Copy link

nobody care this ?

image

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 17, 2018
@Manhazito
Copy link

Still present on React Native 0.57.1… :-/

@GauthierG
Copy link

Still present on 57.7 ...

@kelset
Copy link
Contributor

kelset commented Mar 19, 2019

This issue appears to be solved in RN 0.59:

Screenshot 2019-03-19 at 17 18 06

Using this snippet:

import React, { Component } from 'react';
import { StyleSheet, View, Text } from 'react-native';

export default class App extends Component<> {
  render() {
    return (
      <View style={styles.container}>
        <Text numberOfLines={2} ellipsizeMode="middle">
          Lorem Ipsum is simply dummy text of the printing and typesetting
          industry. Lorem Ipsum has been the industry's standard dummy text ever
          since the 1500s, when an unknown printer took a galley of type and
          scrambled it to make a type specimen book. It has survived not only
          five centuries, but also the leap into electronic typesetting,
          remaining essentially unchanged. It was popularised in the 1960s with
          the release of Letraset sheets containing Lorem Ipsum passages, and
          more recently with desktop publishing software like Aldus PageMaker
          including versions of Lorem Ipsum.
        </Text>
        <Text
          numberOfLines={1}
          ellipsizeMode="middle"
          style={{ marginTop: 20 }}
        >
          Some long text • 10
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'white',
    justifyContent: 'center',
    paddingTop: 40,
    paddingHorizontal: 50
  }
});

Closing.

@kelset kelset closed this as completed Mar 19, 2019
@deathnopool
Copy link

same isuee.
numberOfLines=1 works fine, but not for numberOfLine=2, 3, 4 ...

@Temirtator
Copy link

For some reason this doesnt work for Android

same isuee.
numberOfLines=1 works fine, but not for numberOfLine=2, 3, 4 ...

@jinshin1013
Copy link

@kelset Wait your example shows it it's broken on the Android.

This is still happening on 0.61.5.

@facebook facebook locked as resolved and limited conversation to collaborators Mar 19, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

10 participants