Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SectionList onViewableItemsChanged behaviour difference between iOS and Android/Web #48887

Open
philipbulley opened this issue Jan 23, 2025 · 2 comments

Comments

@philipbulley
Copy link

Description

Expected:
SectionList onViewableItemsChanged should correctly report viewableItems across multiple sections when items from those sections are within the viewport. This is the current behaviour on Android and Web.

Actual:
SectionList onViewableItemsChanged will only report viewableItems for one section at at time, even if items from multiple sections are within the viewport. This is the current behaviour on iOS.

Notes:

  • Using getItemLayout restores the expected behaviour on iOS.
  • The reproducer uses the viewableItems parameter. However, the issue is also true of the changed parameter.
  • I've tested the scenarios with and without passing varying viewabilityConfig.
  • Not the same behaviour as reported in onViewableItemsChanged isn't correct without specifying the header height in getItemLayout #48351. The following statement from that issue is not true of this issue: "If I remove getItemLayout entirely, the logic works fine regardless."

Steps to reproduce

  1. Open the supplied Expo reproducer
  2. Scroll through the list
  3. Observe the logs (messages list the sections with viewable items)
  4. Do the above across multiple platforms, when scrolled to a point where multiple sections are within the viewport:
    1. iOS will incorrectly only report a single section.
    2. Android and Web will correctly report multiple sections.

Reproduced locally in vanilla react-native@0.76.3 with new architecture. Also reproduced locally in react-native@0.75.4 without new architecture.

React Native Version

0.76.3

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 15.2
  CPU: (12) arm64 Apple M2 Pro
  Memory: 139.78 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.12.2
    path: ~/.nvm/versions/node/v20.12.2/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.5.0
    path: ~/.nvm/versions/node/v20.12.2/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/philipbulley/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12700392
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 3.3.0
    path: /Users/philipbulley/.rbenv/shims/ruby
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.3
    wanted: 0.76.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

n/a

Reproducer

https://snack.expo.dev/@pbcodes/onviewableitemschanged-behaviour-difference-between-ios-and-android-or-web

Screenshots and Videos

iOS ❌

Scroll until items from 2 sections are within viewport

Image

Scroll further until the first section has left the viewport

Image

Android ✅

Scroll until items from 2 sections are within viewport

Image

Web ✅

Scroll until items from 2 sections are within viewport

Image
@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - 0.76.6. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants