Skip to content

fix(core): keep the sort scroll key saveable on Android - #179

Merged
xelon-ua merged 1 commit into
mainfrom
fix/saveable-sort-scroll
Dec 2, 2026
Merged

xelon-ua merged 1 commit into
mainfrom
fix/saveable-sort-scroll

Conversation

@xelon-ua

@xelon-ua xelon-ua commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

A sorted table crashed an Android app as soon as its screen's state was saved, for example when another screen opened over it in a navigation back stack. ScrollToTopOnSortChange kept the last sort in rememberSaveable as a SortState, which an Android Bundle cannot hold, so SaveableStateRegistry.performSave threw IllegalArgumentException.

Changes

  • ScrollToTopOnSortChange remembers a text key of the sort (column|order) instead of the SortState itself. A column may be of any type; the key fits a Bundle and still tells a restored sort from a changed one.
  • SortScrollSavedStateTest: a sorted table saves into a registry that accepts only Bundle values; restored with the same sort it keeps its scroll position; restored with another sort it scrolls to the top.
  • CHANGELOG.md: Unreleased entry.

Testing

  • ./gradlew :table-core:jvmTest — green, the new test fails without the fix.
  • ./gradlew spotlessCheck :table-core:detekt — green.

ScrollToTopOnSortChange held the last sort in rememberSaveable as a
SortState. The state starts as null, so it registers, and later holds a
SortState, which an Android Bundle cannot take: the app crashed with
IllegalStateException as soon as the screen's state was saved, for
example when a card opened over a sorted list.

The saved state now keeps a text key of the column and the order, which
is all the comparison needs.
@xelon-ua
xelon-ua merged commit 770082b into main Dec 2, 2026
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