react / react/react-native

Inconsistency in View Alignment within Text Component on Android/iOS Platforms

Abierto
#43,086 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Issue: Author Provided Repro Needs: Triage :mag: Newer Patch Available Platform: Android Platform: iOS
Lenguaje dominante
C++
Estrellas
127k
Forks
25.3k
Merge medio
1 d 23 h
PR fusionados (30 d)
4

Descripción

Description

When wrapping View children in a Text component, the views are displayed inline with the text on web platforms. However, on Android and iOS platforms, adjusting the line height of the parent Text component causes the View children to no longer be inline with the text.

Steps to reproduce
  1. Create a parent Text component.
  2. Wrap View children within the Text component.
  3. Note how the views are inline with the text on web platforms.
  4. Adjust the line height of the parent Text component.
  5. Observe that the views are no longer inline with the text on Android and iOS platforms.

export default function App() {
  return (
    <SafeAreaView style={styles.container}>
      <Text style={styles.text} >
      Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
      eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
      voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
      clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
      amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr
      <View
        style={{
          borderRadius: 40,
          height: 50,
          paddingHorizontal: 32,
          backgroundColor: 'yellow'
        }}
      >
        <Text>Button Text</Text>
      </View>
    </Text>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
 text: {
    fontSize: 17,
    lineHeight: 29
  },
});
React Native Version

0.72.4

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info
System:
  OS: macOS 14.3.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 32.88 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.6.1
    path: /opt/homebrew/bin/node
  Yarn:
    version: 4.0.2
    path: /opt/homebrew/bin/yarn
  npm:
    version: 9.9.2
    path: ~/Documents/dev/finanztip/app-components/node_modules/.bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11076708
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.17
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.4
    wanted: 0.72.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
Stacktrace or Logs
none
Reproducer

https://snack.expo.dev/CABd_oOlH8QkEUCdWhRkL

Screenshots and Videos

Screenshot_1708334374
Simulator Screenshot - iPhone 15 - 2024-02-19 at 10 18 37

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 de Expo Snack enlazado y compara el diseño de Text y View con el lineHeight especificado en Android, iOS y web. Confirma la diferencia de alineación específica de cada plataforma e identifica los puntos de entrada nativos relevantes del diseño de texto antes de cambiar el comportamiento; se considera terminado cuando la View ajustada por salto de línea permanece inline de forma consistente en las plataformas afectadas.

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

Evaluación

Stack tecnológico
android, ios, react-native
Área
mobile
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.