Repository navigation
fix(android): hand drags to a scrollable that mounts after the sheet presents - #1024
Open
isaacrowntree wants to merge 2 commits into
Open
isaacrowntree wants to merge 2 commits into
isaacrowntree wants to merge 2 commits into
Conversation
…presents
BottomSheetBehavior looks for its nested scrolling child in onLayoutChild
only. When scrollableRef's scroll view mounts after the sheet has presented
(content that shows a loader first), setScrollableHandle turns nested
scrolling on for it, but only a later layout tells the behavior about it.
Today that layout comes from finalizeUpdates() adding the grabber view back,
so with grabber={false} none follows.
The behavior then drags the sheet itself. The scroll view's cancelled touch
stream stops its nested scroll while the sheet is still at the expanded
offset, which sets the state back from DRAGGING, and the release skips the
dismissThreshold="short" rule: a short pull springs back.
Request a layout when the handle changes, as containerViewScrollViewDidChange
already does for a remounted scroll view.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UdycNhpCYe25QHqrd5wdkQ
|
@isaacrowntree is attempting to deploy a commit to the lodev09 Team on Vercel. A member of the Team first needs to authorize it. |
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UdycNhpCYe25QHqrd5wdkQ
This branch has not been deployed
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.
Summary
On Android, a sheet with
grabber={false}anddismissThreshold="short"does not close on a short pull when itsscrollableRefscroll view mounts after the sheet has presented, for example content that shows a loader first and the list once it has loaded. The pull springs back, and only a pull long or fast enough for Material's own release rule closes the sheet.BottomSheetBehaviorlooks for its nested scrolling child inonLayoutChildonly. When the handle arrives,setScrollableHandleturns nested scrolling on for the scroll view, but nothing in that call lays the sheet out. Onmaina layout still follows most of the time, as a side effect:finalizeUpdates()runssetupGrabber(), which removes the grabber view and adds it back. Withgrabber={false}there is nothing to add, so no layout follows and the behavior never learns about the scroll view.The behavior then drags the sheet itself. When it takes the gesture, the scroll view's cancelled touch stream stops its nested scroll while the sheet is still at the expanded offset, and Material's
onStopNestedScrollsets the state back fromSTATE_DRAGGING. At the lift,wasDraggingis false inTrueSheetBottomSheetBehavior.onTouchEvent, soreleaseState(the short threshold) is skipped and Material's own rule decides.Logged on
mainwith temporaryLog.dlines, one 15% pull:With a grabber, or with this change,
onLayoutChildfollowssetScrollableHandlewithin 10 ms and the same pull ends inonStopNestedScroll nestedDragged=true.The fix requests a layout when the handle changes, which is what
containerViewScrollViewDidChangealready does for a remounted scroll view (#564). It is one call inTrueSheetView.setScrollableHandle, after the existing early return for an unchanged handle.Type of Change
Test Plan
Repro branch, one commit on
mainthat only touches the example:isaacrowntree/react-native-true-sheet@repro/android-late-scrollable. It adds a "Late Scrollable" sheet to the Standard screen and opens the bare example on that screen. The sheet hasdetents={[1]},grabber={false},dismissThreshold="short", and itsScrollViewmounts 1.5 s afteronDidPresent.yarn bare android, tap Late Scrollable, wait for the list.main: it springs back.Measured on the bare example on an API 36 emulator (1080x2400). Each trial restarts the app, presents the sheet, waits 4 s, sends
adb shell input swipe 540 500 540 <end> 400, and 2.5 s later checks withuiautomator dumpwhether "Item #1" is still on screen. Counts are trials where the sheet dismissed:main(da96a5d),grabber={false}grabber={false}Control, the same sheet with the default grabber:
mainThe one miss with this PR ran right after a Gradle build, with the machine under heavy load. It did not come back in 6 more runs, and I did not find its cause.
Also ran
yarn typecheck,eslint "**/*.{ts,tsx}",yarn test(175 passed) andktlintonTrueSheetView.kt, and./gradlew :app:assembleDebugfor the bare example. Not tested on a physical device. The Android sources are unchanged between 4.1.0 andmain.Screenshots / Videos
None. The table above is from
adbruns.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01UdycNhpCYe25QHqrd5wdkQ