react / react/react-native

Scroll position not maintained after resume on iOS

Ouverte
#54,979 5 commentaires 2 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

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

Description

Description

The scroll position of a ScrollView that has been scrolled to the bottom is not maintained on resume after being backgrounded on iOS.

The position appears to be reset to landscape when the device is in portrait. In addition to triggering an unexpected scroll, the layoutMeasurement.height of the scroll event indicate that the device orientation has changed to portrait. However, no corresponding onLayout event is triggered, and the app resumes in landscape.

Initially I thought this was an issue with FlashList but I found that it can be reproduced with ScrollView alone.

Steps to reproduce
  1. Run the Snack on an iPad simulator
  2. Rotate the screen to landscape (app must be fullscreen)
  3. Scroll to the bottom
  4. Background the app
  5. Wait a few seconds
  6. Open the app
  7. See that the ScrollView position has changed
React Native Version

0.83.1

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info
System:
  OS: Linux 6.17 Debian GNU/Linux 13 (trixie) 13 (trixie)
  CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Memory: 11.53 GB / 23.24 GB
  Shell:
    version: "5.9"
    path: /usr/bin/zsh
Binaries:
  Node:
    version: 22.21.0
    path: /usr/bin/node
  Yarn:
    version: 1.22.22
    path: /usr/bin/yarn
  npm:
    version: 10.9.4
    path: /usr/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
IDEs:
  Android Studio: AI-252.27397.103.2522.14514259
Languages:
  Java: Not Found
  Ruby:
    version: 3.0.2
    path: /home/mhoran/.rbenv/shims/ruby
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
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
Stacktrace or Logs

https://github.com/user-attachments/assets/6cc7ab12-6996-4576-86d3-d9f696875386

MANDATORY Reproducer

https://snack.expo.dev/@mhoran/restless-green-graham-crackers

Screenshots and Videos

No response

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 reproducer Snack obligatoire sur un simulateur iPad et suivez les étapes indiquées de rotation, de défilement, de mise en arrière-plan et de reprise. Comparez layoutMeasurement.height de l’événement de défilement de ScrollView avec l’orientation de l’appareil et vérifiez si un événement onLayout se produit pendant la reprise. Le travail est considéré comme terminé lorsque la position de défilement reste stable et que l’état d’orientation/de layout est cohérent après la réouverture de l’application.

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

Évaluation

Stack technique
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.