react / react/react-native

TextInput with multiline and fixed height shows inconsistent text positioning on initial render

Ouverte
#54,304 7 commentaires 3 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Component: TextInput Needs: Triage :mag:
Langage dominant
C++
Étoiles
127k
Forks
25.3k
Merge moyen
1 j 23 h
PR mergées (30 j)
4

Description

Description

When using a TextInput with multiline={true}, fixed height, and textAlignVertical="top", the text positioning is inconsistent depending on navigation path. When a user first opens the app and navigates to a screen containing long text that overflows the TextInput, the text appears "squashed" towards the top with content cut off under the border. However, if the user navigates back to the home screen, opens a note with shorter content first, then returns to the long note, the text positioning displays correctly.

This appears to be a layout initialization timing issue where the TextInput doesn't properly calculate its content positioning on first render when dealing with overflow content.

Steps to reproduce
  1. Clone the reproduction repository: git clone https://github.com/Jakes-Git-Hub/Multi-Line-Test.git
  2. Install dependencies with npm install
  3. Start the app with npx expo start
  4. Open the app and immediately tap on either "Long Note Example" or "Another Overflow Note"
  5. Observe that the text appears squashed towards the top with content cut off under the border
  6. Navigate back to the home screen using the back button
  7. Tap on the "Short" note (single word content)
  8. Navigate back and tap on one of the long notes again
  9. Observe that the text now displays correctly with proper positioning

Also if i go into another long note after initially opening a long note, the text positioning adjusts to a middle ground between squashed and what would be the text position if sequence was long note -> short note -> LN.

React Native Version

0.81.5

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info
System:
  OS: Windows 11 10.0.26100
  CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1255U
  Memory: 1.77 GB / 15.68 GB
Binaries:
  Node:
    version: 22.14.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn: Not Found
  npm:
    version: 11.6.2
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: Not Found
  Visual Studio: Not Found
Languages:
  Java: Not Found
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.5
    wanted: 0.81.5
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
Stacktrace or Logs
No crash occurs - this is a layout/rendering issue. The TextInput renders but with incorrect text positioning on initial load. No error messages or stack traces are generated.
MANDATORY Reproducer

https://github.com/Jakes-Git-Hub/Multi-Line-Test

Screenshots and Videos

https://github.com/user-attachments/assets/567f5f49-a871-4b1a-8614-4208b0c13a1f

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par exécuter le reproducteur obligatoire de Multi-Line-Test avec React Native 0.81.5 et comparez le chemin initial des notes longues avec le chemin de navigation des notes courtes sur iOS. Examinez le comportement de TextInput multiligne avec une hauteur fixe, un contenu qui déborde et textAlignVertical="top". Le travail est terminé lorsque les notes longues ont une position du texte cohérente lors de leur premier rendu et après la navigation, sans que le contenu soit coupé sous la bordure.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
ios, react-native
Domaine
mobile
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.