material-components / material-components/material-components-android

[BottomSheetBehavior] Collapse/Expand threshold is different for NestedScrollView

オープン
#1,055 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

bug Widget: BottomSheet
主要言語
Java
スター
17.4k
フォーク
3.2k
PR マージ指標
30日以内にマージされた PR はありません

説明

Description:
When dragging a bottom sheet (without flinging it) and then letting go, the expand/collapse behavior is different based on if the user started the drag from within a NestedScrollView versus any other type of View.

When starting a drag from outside of a NestedScrollView the BottomSheetBehavior appears to take the velocity of the pointer into account (both horizontal and vertical) when determining to expand or collapse. If there is no vertical velocity or if there is more horizontal velocity than vertical then the bottom sheet will move to whichever of the expand or collapse positions is closest.

When starting a drag from within a NestedScrollView the BottomSheetBehavior doesn't appear to take the pointer velocity into account. All movement is treated as if the user was flinging the view so any slight movement in the upward direction will expand the bottom sheet and any movement in the downward direction will collapse the bottom sheet.

Expected behavior:
I was expecting the expand/collapse behavior to be the same between NestedScrollView Views and other types of Views. The current behavior makes user interaction within a NestedScrollView overly sensitive. If a user swipes horizontally on a control within a NestedScrollView it may expand/collapse the bottom sheet unexpectedly if there is any amount of upward or downward motion.

Source code:
I posted about this issue on StackOverflow. Sample code that illustrates this issue can be found there:
https://stackoverflow.com/questions/60284004/bottomsheet-has-no-drag-threshold-when-user-initiates-drag-from-within-nestedscr

It looks like it's this check in the onViewReleased method that results in the desired behavior which is not present in the onStopNestedScroll method:
https://github.com/material-components/material-components-android/blob/8e8d20c94f3573f7f7418f3971fbbc41a4fa83bd/lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java#L1345-L1347

Android API version: 28

Material Library version: com.google.android.material:material:1.2.0-alpha04

Device: Pixel

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

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

はじめの一歩

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

調査の方向性

lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java から始め、issue で引用されている onViewReleased のチェックと onStopNestedScroll を比較します。リンクされた StackOverflow のサンプルを使って NestedScrollView のケースを再現し、その後、水平ドラッグまたは垂直速度が低いドラッグが、他のビューと同じ展開/折りたたみのしきい値を使用し、意図しない状態変更が発生しないことを確認します。

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

評価

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

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

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