Skip to content

[BottomSheet] Fix velocity-based dismiss through nested scroll path#5077

Open
harveylx wants to merge 1 commit intomaterial-components:masterfrom
harveylx:fix/bottomsheet-nested-scroll-velocity-dismiss
Open

[BottomSheet] Fix velocity-based dismiss through nested scroll path#5077
harveylx wants to merge 1 commit intomaterial-components:masterfrom
harveylx:fix/bottomsheet-nested-scroll-velocity-dismiss

Conversation

@harveylx
Copy link
Copy Markdown

@harveylx harveylx commented Apr 25, 2026

closes #5076

onStopNestedScroll called getYVelocity() which returned 0 because activePointerId was already reset by onInterceptTouchEvent(ACTION_UP). Store the fling velocity from onNestedPreFling and use it in onStopNestedScroll so shouldHide() receives the real velocity.

Changes

  • Added lastNestedFlingVelocityY field to capture fling velocity from the nested scroll path
  • In onNestedPreFling, store velocityY when the fling is consumed
  • In onStopNestedScroll, prefer the stored fling velocity over getYVelocity() (which returns 0 due to the invalid pointer ID)
  • Reset the stored velocity in onStartNestedScroll at the beginning of each gesture

Thanks for starting a pull request on Material Components!

Don't forget:

  • Identify the component the PR relates to in brackets in the title.
    [Buttons] Updated documentation
  • Link to GitHub issues it solves. closes #1234
  • Sign the CLA bot. You can do this once the pull request is opened.

Contributing
has more information and tips for a great pull request.

onStopNestedScroll called getYVelocity() which returned 0 because
activePointerId was already reset by onInterceptTouchEvent(ACTION_UP).
Store the fling velocity from onNestedPreFling and use it in
onStopNestedScroll so shouldHide() receives the real velocity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BottomSheet] Velocity-based dismiss does not work when fling originates from nested scrolling child

1 participant