react / react/react-native

ScrollView's scrollToEnd scrolls too far on android

オープン
#47,959 コメント 4 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Component: ScrollView Issue: Author Provided Repro Platform: Android Resolution: PR Submitted
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

ScrollView's scrollToEnd method gives different results on iOs and Android.

Expected behaviour:
ScrollView's scrollToEnd method should function consistently across platforms. Ideally The view should scroll until the bottom of the content reaches the bottom of the view.

Actual behaviour:
On iOs the view tries to scroll until the bottom of the content reaches the bottom of the view.
On Android the view tries to scroll until the bottom of the content reaches the top of the view.

This is especially annoying if you add content while the view is scrolling, as it then scrolls too far, or if you have an animation of content being added to slide in from the bottom.

Steps to reproduce
  1. Open the provided snack on Android
  2. Press the button labeled "Press me!"
  3. The view scrolls until element "Test 50" reaches the top of the screen
  4. Open the provided snack on iOs
  5. Press the button labeled "Press me!"
  6. The view scrolls until element "Test 49" reaches the bottom of the screen
React Native Version

0.76.3

Affected Platforms

Runtime - Android

Output of npx react-native info
System:
  OS: macOS 14.7
  CPU: (10) arm64 Apple M1 Pro
  Memory: 124.23 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.11.1
    path: ~/.nvm/versions/node/v20.11.1/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.4
    path: ~/.nvm/versions/node/v20.11.1/bin/npm
  Watchman:
    version: 2024.09.16.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.1
      - iOS 18.1
      - macOS 15.1
      - tvOS 18.1
      - visionOS 2.1
      - watchOS 11.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12550806
  Xcode:
    version: 16.1/16B40
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 18.0.2.1
    path: /Users/chriscoerdes/.jenv/shims/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/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://github.com/coerdes-chris/react-native-scrollview

Screenshots and Videos

https://github.com/user-attachments/assets/ad2a0bcd-4c59-4291-8891-9f2dfbd1d13f

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供された再現手順と ScrollView's scrollToEnd の Android 実装から始め、その挙動を issue に記載された iOS の結果と比較します。スクロール中にコンテンツが追加された場合の挙動を確認します。既存のテスト構成で対応できる場合はリグレッションテストのカバレッジを追加し、Android が iOS と一貫してコンテンツの下端をビューの下端に揃えた状態で停止すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
android, react-native
領域
mobile-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。