Skip to content

[Text on Android]: setting selectable to true breaks the text truncation and lineHeight on Android #48921

@dariakoko

Description

@dariakoko

Description

I use Text component that has to contain selectable text and should be truncated if it extends the width of the parent component.
On iOS everything works fine. On Android if I set selectable={true} truncation and line height of the text are breaking.

Steps to reproduce

  1. import Text component from react-native
  2. render Text component, add selectable={true}, numberOfLines={1}
  3. the text is cut off instead of being truncated, the line height is bigger than it should be, the top of the second line of text is visible

React Native Version

0.75.4

Affected Platforms

Runtime - Android

Output of npx react-native info

-

Stacktrace or Logs

-

Reproducer

https://github.com/dariakoko/text-component-on-android

Screenshots and Videos

Image
      <View style={{width: 200}}>
        <Text style={{color: 'green'}}>default: </Text>
        <Text style={{backgroundColor: 'yellow'}}>
          Some long very very very very very long text
        </Text>

        <Text>-------------</Text>

        <Text style={{color: 'green'}}>not selectable: </Text>
        <Text numberOfLines={1} style={{backgroundColor: 'yellow'}}>
          Some long very very very very very long text
        </Text>

        <Text>-------------</Text>

        <Text style={{color: 'red'}}>selectable (issue): </Text>
        <Text
          selectable={true}
          numberOfLines={1}
          style={{backgroundColor: 'yellow'}}>
          Some long very very very very very long text
        </Text>
        <View style={{height: 20, backgroundColor: 'pink'}}></View>
      </View>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions