Skip to content

fix(library): keep scroll position when leaving folders/albums - #2953

Open
phon-t wants to merge 1 commit into
PixelPlayerHQ:masterfrom
phon-t:fix/2814-scroll-position
Open

phon-t wants to merge 1 commit into
PixelPlayerHQ:masterfrom
phon-t:fix/2814-scroll-position

Conversation

@phon-t

@phon-t phon-t commented Nov 3, 2026

Copy link
Copy Markdown

Fixes #2814

Exiting a folder or album page reset the library scroll position to the top. The Albums and Folders tabs built their list/grid states with plain remember state, so the state died with the composition: for Albums when leaving Library for an album detail page, and for Folders because each folder destination inside AnimatedContent got its own fresh list state.

Changes:

  • Added a pure LibraryScrollPositionStore, held in LibraryViewModel (which outlives both transitions), saving a tab's first visible item and offset on dispose and restoring it once on return.
  • Albums tab (list and grid): positions saved separately; restore waits for paging to load the saved index (or reach end of pagination) instead of clamping to the first partial page.
  • Folders tab: position saved per folder path plus playlist-view mode, restored once when that folder is re-entered.
  • Sort changes still scroll to item 0 and are not undone by the restore.
  • Added LibraryScrollPositionStoreTest covering in-range restore, empty-list null, clamping to the last item when items were removed, per-key independence, and negative-index/clear.

Testing (honest):

  • The project's own Gradle test task could not be run on the machine that prepared this fix: the Gradle toolchain download for the required JetBrains JDK 21 failed from Java, and the Gradle daemon dispatch failed repeatedly, so no Gradle test result is claimed here.
  • As a partial check, the exact LibraryScrollPositionStore and LibraryScrollPositionStoreTest files from this branch were compiled and run standalone with kotlinc 2.2.20 and JUnit 5.11.4: 5 tests, 5 passed, 0 failed. That is not a substitute for the project's Gradle test task, which CI should run.
  • Not run on a device or emulator. Songs, Artists and Playlists tabs were left untouched, and switching to another main tab (Home/Search) and back was not the reported repro and was not verified.

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.

[Bug]: Exiting an folder/album page resets scroll position to the top

1 participant