[Text on Android]: setting selectable to true breaks the text truncation and lineHeight on Android
Nadie ha tomado este issue todavía.
- 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
- import Text component from react-native
- render Text component, add
selectable={true},numberOfLines={1} - 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
<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
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- 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