Skip to content

android: Let a pull to refresh around a sideways scroll view take the drag - #4215

Merged
huacnlee merged 1 commit into
longbridge:mainfrom
zsakvo:android-pull-refresh-around-row
Dec 3, 2026
Merged

huacnlee merged 1 commit into
longbridge:mainfrom
zsakvo:android-pull-refresh-around-row

Conversation

@zsakvo

@zsakvo zsakvo commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Description

On Android, a vertical Scroll / List with onRefresh cannot be pulled to refresh when the downward drag starts on a horizontal scroll view inside it (a row of cards, a horizontal List, a carousel). Starting the same drag anywhere else refreshes.

Cause. The inner horizontal ScrollBox claims the touch on its down (claim asks the views around not to intercept). Past the slop it hands a drag it has no content for to the views around only when aroundTakes says one of them takes it: its own pull (canPull, always false for a horizontal view), a Box pan around it, or an ancestor that can still scroll that way. A refreshing list at its top cannot scroll up (canScrollVertically(-1) is false), so nothing took the drag, the row kept it, and the outer onInterceptTouchEvent that starts the pull never saw it.

Fix. aroundPans also counts a ScrollBox around that would start its pull now (takesPull: not refreshing and canPull, the same condition as its onInterceptTouchEvent, which now uses it too). The inner view then lets go, and the outer list's onInterceptTouchEvent starts the pull on the next move from the startY it recorded on the down. Sideways drags and drags up are unchanged. iOS is not affected: UIKit already gives the pull to the outer scroll view.

Screenshot

No visual change; the behavior is covered by the native test below.

How to Test

New test examples/gallery/tests/refresh-around-row.test.tsx (fixture refresh-around-row.tsx, a refreshing page with a horizontal row of cards), on an arm64 Android emulator:

./target/debug/nsh test examples/gallery/tests/refresh-around-row.test.tsx --target android
  • Without the fix: a downward drag on a sideways row pulls the page around it to refresh fails (refreshes: 0).
  • With the fix: both tests pass (the second checks that a sideways drag still scrolls the row and does not refresh).

Related nested-scroll tests on the same emulator, with the fix: zoom-in-pager, pan-over-scroll and sheet-scroll pass. In pan-around-scroll, a mostly sideways diagonal ... pans the view fails on this emulator with and without this change (the fixture has no pull to refresh, so it does not reach the new branch).

Not clean on main with rustc 1.98.1, unrelated to this change: cargo xtask clippy-android reports thread_local const-initializer lints in nsh-core, and nsh check examples/gallery reports a type error in tests/sheet-alert.test.tsx.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (if any) is accurate.
  • Passed cargo test --workspace, cargo +nightly fmt --all and clippy (including the Catalyst and Android runs for platform code). (Java only; the Android clippy run fails on main as noted above.)
  • Ran the related examples/gallery demos on iOS and Android (if the change is visible or platform-specific). (Android, via the native tests above.)

🤖 Generated with Claude Code

… drag

A sideways scroll view (a row of cards) claims each touch on its down and
hands a drag it has no content for to the views around only when one of
them takes it: its own pull to refresh, a pan around it, or a scroll view
around it that can still move that way. A refreshing list at its top
cannot scroll up, so a downward drag that starts on the row stayed with
the row and the list never refreshed.

A scroll view around that would start its pull now also takes the
downward drag, as its own onInterceptTouchEvent decides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@huacnlee huacnlee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bounded Android fix: a downward drag that starts on a sideways row now lets the refreshing list around it pull.

  • Defect: in a refreshing Scroll, a downward drag starting inside a horizontal child Scroll was kept by the child, so pull to refresh never started.
  • crates/nsh-platform-android/java/com/longbridge/nsh/ScrollBox.java (aroundPans): for a mostly vertical downward drag it yields when an ancestor ScrollBox takesPull(). takesPull() (not refreshing and canPull() at top) is reused in onInterceptTouchEvent, so behaviour there is unchanged.
  • Tests: examples/gallery/tests/refresh-around-row.test.tsx covers the downward drag (refreshes, row stays) and the sideways drag (row scrolls, no refresh); Android only.
  • Public API: none.
  • CI: not run (fork workflows are waiting for maintainer approval).

Reviewed at eb6cb50 (diff only, not built).

🤖 Noop (reviewer) · AI agent acting for @huacnlee

@huacnlee huacnlee added the Approved Review approved label Dec 3, 2026
@huacnlee
huacnlee merged commit bb80144 into longbridge:main Dec 3, 2026
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Review approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants