react / react/react-native

FlatList > Orientation change > Different Item Heights for Portrait and Landscape Do Not Persist Scroll Position Correctly

Đang mở
#48,325 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Component: FlatList Issue: Author Provided Repro
Ngôn ngữ chính
C++
Star
127k
Fork
25.3k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
4

Mô tả

Description

render items have a different height (landscape = 50 portrait = 200)

When scrolling down a list of flat list items, when the orientation is changed (from portrait to landscape and vise versa), the current scroll position is incorrect.

It seems to retail the current scroll position in pixels and not by the viewable items that were present pre orientation change?

Note that if you're at the top of the list, there is no issue. It's only when you have scrolled down the list.

I have tried capturing the top viewable item on onViewableItemChanged and attempting to use the ref's scrollToIndex, but to no avail.

Steps to reproduce

Install and execute the application
Scroll down the list
Change orientation
The previously viewable items are no longer in view

React Native Version

0.76.5

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info
npm verbose cli C:\Program Files\nodejs\node.exe C:\Users\MarkAustin\AppData\Roaming\nvm\v22.12.0\node_modules\npm\bin\npm-cli.js
npm info using npm@10.9.0
npm info using node@v22.12.0
npm verbose title npm exec react-native info
npm verbose argv "exec" "--" "react-native" "info"
npm verbose logfile logs-max:10 dir:d:\workspace\npm-cache\_logs\2024-12-18T15_49_53_732Z-
npm verbose logfile d:\workspace\npm-cache\_logs\2024-12-18T15_49_53_732Z-debug-0.log
info Fetching system and libraries information...
(node:27612) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
System:
  OS: Windows 11 10.0.26100
  CPU: (22) x64 Intel(R) Core(TM) Ultra 7 155H
  Memory: 12.54 GB / 31.70 GB
Binaries:
  Node:
    version: 22.12.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn: Not Found
  npm:
    version: 10.9.0
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-242.23339.11.2421.12550806
  Visual Studio:
    - 17.12.35506.116 (Visual Studio Enterprise 2022)
Languages:
  Java: 17.0.13
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.5
    wanted: 0.76.5
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

npm verbose cwd D:\Workspace\rn-replications\flatlist-orientiation\ReproducerApp
npm verbose os Windows_NT 10.0.26100
npm verbose node v22.12.0
npm verbose npm  v10.9.0
npm verbose exit 0
npm info ok
Stacktrace or Logs
N/A
Reproducer

https://github.com/markaustinws/flatlist-orientiation

Screenshots and Videos

flatlist orientation change

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách chạy reproducer flatlist-orientiation được liên kết và quan sát FlatList sau khi cuộn và thay đổi hướng. So sánh hành vi này với các lần thử onViewableItemChanged và scrollToIndex đã được báo cáo; được xem là hoàn thành khi các mục trước đó có thể nhìn thấy vẫn còn trong vùng hiển thị sau khi chuyển đổi giữa chế độ dọc và ngang trên Android và iOS.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
react-native
Lĩnh vực
mobile
Loại issue
Lỗi
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
28/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.