react / react/react-native

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

Abierto
#48,921 25 comentarios 5 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Needs: Triage :mag: Platform: Android
Lenguaje dominante
C++
Estrellas
127k
Forks
25.3k
Merge medio
1 d 23 h
PR fusionados (30 d)
4

Descripción

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>

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con el reproductor enlazado en https://github.com/dariakoko/text-component-on-android e inspecciona el comportamiento del componente Text de React Native en Android con selectable={true} y numberOfLines={1}. Compáralo con los casos no seleccionables y de iOS; se considera terminado cuando el texto seleccionable se trunca correctamente y conserva la altura de línea esperada en Android.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
android, react-native
Área
mobile-dev
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.