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

[BottomSheetBehavior] Collapse/Expand threshold is different for NestedScrollView

Ouverte
#1,055 5 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

bug Widget: BottomSheet
Langage dominant
Java
Étoiles
17.4k
Forks
3.2k
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

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 lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java, en comparant la vérification de onViewReleased citée dans l’issue avec onStopNestedScroll. Reproduisez le cas de NestedScrollView à l’aide de l’exemple StackOverflow lié, puis vérifiez que les glissements horizontaux ou à faible vitesse verticale utilisent le même seuil d’expansion/réduction que les autres vues, sans changements d’état accidentels.

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

Évaluation

Stack technique
android, java
Domaine
mobile
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.