Skip to content

zero-swift: a list stuck to the bottom takes the user's first scroll - #30

Merged
tmm merged 1 commit into
mainfrom
swift-stuck-first-scroll
Oct 25, 2026
Merged

tmm merged 1 commit into
mainfrom
swift-stuck-first-scroll

Conversation

@tmm

@tmm tmm commented Oct 25, 2026

Copy link
Copy Markdown
Member

In a VirtualList or VirtualListView with stickToBottom, the user's first scroll up could be pulled back to the bottom.

Cause: VirtualizerCore.setScrollOffset sets programmaticScroll before asking the host to scroll. When the host clamps the target to where it already is, as on a scroll past the bottom of a list opened at its last row, no didScroll follows, so the flag stays set. The user's next scroll is then taken for the core's own: stuck isn't measured again, and the re-pin pulls the rows back against the scroll.

Fix: setScrollOffset clears the flag and returns false when the host didn't move.

Found while investigating a one-frame wrong move in the iPhone chat frame probe on #29. It's the likely cause of that failure, but that isn't proven. The bug is on main and in 0.4.4, so it ships separately.

Checks (Linux): Swift 216 tests in 41 suites, also under ulimit -s 512; strict lint. The new LayoutHost test fails without the fix (the row ends at −16.1 instead of moving 20.5 pt) and passes with it. On macOS, ZeroVirtualTests 101/101 and AppleTests VirtualList/VirtualListView 8/8 passed with the fix.

…roll

When the core scrolled a host to where the host clamped it, no didScroll
followed, so programmaticScroll stayed set and the user's next scroll was
taken for the core's own: stuck wasn't measured again, and the list
pulled the rows back to the bottom against the scroll. setScrollOffset
now clears the flag when the host didn't move.

Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859
Co-authored-by: tmm <tmm@tmm.dev>
@tmm
tmm merged commit 76380f0 into main Oct 25, 2026
28 of 29 checks passed
@tmm
tmm deleted the swift-stuck-first-scroll branch October 25, 2026 22:49
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.

2 participants