UI: improve swipe to dismiss reliability on More bottom sheet#6746
Open
Akul-Tyagi wants to merge 1 commit intocommons-app:mainfrom
Open
UI: improve swipe to dismiss reliability on More bottom sheet#6746Akul-Tyagi wants to merge 1 commit intocommons-app:mainfrom
Akul-Tyagi wants to merge 1 commit intocommons-app:mainfrom
Conversation
Replaced ScrollView with NestedScrollView and removed nestedScrollingEnabled to prevent inflation crashes while ensuring smooth dismissal.
|
✅ Generated APK variants! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6744
The Problem
Currently, the "More" bottom sheet content is wrapped in a standard ScrollView. BottomSheetBehavior relies on nested scrolling signals from child content to handle drag and dismiss gestures. Because plain ScrollView does not consistently hand off these gesture signals, the swipe down to dismiss behavior is flaky and often fails to register.
The Solution & Justification
I replaced ScrollView with NestedScrollView in both fragment_more_bottom_sheet.xml and fragment_more_bottom_sheet_logged_out.xml. NestedScrollView is specifically designed to interoperate with BottomSheetBehavior, ensuring reliable nested scroll handoffs so the swipe-down gesture consistently dismisses the modal.
Additionally, I ensured the android:nestedScrollingEnabled="true" attribute was completely omitted from the layout XML. Keeping that attribute on certain device configurations triggers an InflateException (NPE) during inflation. Removing it keeps the fix minimal and crash-safe while preserving the improved scroll behavior.
Alternative Solutions Considered
I briefly considered keeping the ScrollView and programmatically overriding the touch interception logic directly inside the Fragment or tuning the BottomSheetBehavior callbacks in Kotlin. However, I discarded this approach because it introduces unnecessary code complexity. Updating the XML to use the framework-recommended NestedScrollView achieves the correct behavior with a much smaller, cleaner footprint.
Testing Performed
Videos
Before (Flaky dismiss):
Screen_Recording_20260316_201319_Commons.mp4
After (Smooth dismiss):
Screen_Recording_20260316_201449_Commons.mp4