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

[BottomSheetBehavior] Collapse/Expand threshold is different for NestedScrollView

Abierto
#1,055 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug Widget: BottomSheet
Lenguaje dominante
Java
Estrellas
17.4k
Forks
3.2k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java, comparando la comprobación de onViewReleased citada en el issue con onStopNestedScroll. Reproduce el caso de NestedScrollView usando el ejemplo enlazado de StackOverflow y verifica después que los arrastres horizontales o con baja velocidad vertical usen el mismo umbral de expansión/colapso que las demás vistas, sin cambios de estado accidentales.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
android, java
Área
mobile
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.