Repository navigation
fix(core): keep the sort scroll key saveable on Android - #179
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
ScrollToTopOnSortChangekept the last sort inrememberSaveableas aSortState, which an AndroidBundlecannot hold, soSaveableStateRegistry.performSavethrewIllegalArgumentException.Changes
ScrollToTopOnSortChangeremembers a text key of the sort (column|order) instead of theSortStateitself. A column may be of any type; the key fits aBundleand 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.