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

[BottomSheetBehaviour] Fine-tune dismiss behaviour

Open
#1,988 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request Widget: BottomSheet
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
We are using a persistent bottom sheet with the BottomSheetBehavior.
Flags:
`app:behavior_halfExpandedRatio="0.3"`
` app:behavior_hideable="true"`
`app:behavior_skipCollapsed = "true"`

When the bottom sheet is with state expanded it dismisses relatively easily. You don't have to have either too much velocity or go too much far down.
After some debugging, I found out my problem was in `onStopNestedScroll` and in `onViewReleased`. The bottom sheet has `skipCollapsed == true` and `hideable ==true` which will return `true` in the method `shouldHide`.

**Describe the solution you'd like**
Dismissing behaviour varies depending on what flags are set. A possible solution is to make the `ViewDragHelper.Callback` an interface and implement it in the `BottomSheetBehavior`. Then you would be able to fine-tune custom logic.

**Describe alternatives you've considered**
We can override the behaviour and override `onStopNestedScroll`, but `onViewReleased` is part of the `
ViewDragHelper.Callback`.
At the moment we have overridden all the behaviour, but it means handling theming and having to merge it manually.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading BottomSheetBehavior's onStopNestedScroll, onViewReleased, and shouldHide paths, along with the ViewDragHelper.Callback integration. Determine how skipCollapsed and hideable affect dismissal, then define and verify a customizable callback approach without requiring consumers to reimplement theming or the whole behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.