Skip to content

Open a view at the top when it fills in after starting empty - #25

Merged
bardesss merged 1 commit into
mainfrom
fix-scroll-top
Nov 1, 2026
Merged

bardesss merged 1 commit into
mainfrom
fix-scroll-top

Conversation

@bardesss

@bardesss bardesss commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Opening a feed could land on the caught up footer instead of the first item.

Cause

select() first shows the stored ids for the view, which can be an empty list, then refreshes. The scroll rule only jumped to the top when the previous snapshot was non-empty (!shownIds.isNullOrEmpty()), so going from empty to filled kept the LazyListState index from the previous view, which pointed at the footer.

Fix

  • The rule moves into TopOnNewSnapshot(ids, listState).
  • Only the very first snapshot (no earlier one shown) keeps a restored position. Any later change of ids scrolls to item 0, including empty to non-empty.

Tests

TopOnNewSnapshotTest covers the first snapshot keeping its position, a changed snapshot starting at the top, and a view that opens empty then fills. The last one fails with the old guard. Unit tests, lint and assembleRelease pass.

@bardesss
bardesss merged commit e934d70 into main Nov 1, 2026
1 check passed
@bardesss
bardesss deleted the fix-scroll-top branch November 1, 2026 10:27
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.

1 participant