Repository navigation
Conversation
Bottom sheets lost everything on a configuration change: the open target (which sheet, which dose or entry) and the typed fields were plain remember state, so a rotation dismissed the sheet and dropped the draft. - Today, Journal and the item editor keep their open sheet in rememberSaveable; sheet targets, LogTarget and Occurrence are @serializable and stored through a JSON saver (StateSavers.kt). - Sheet content runs under its own SaveableStateHolder (rememberSaveableSheetContent), so fields inside ModalBottomSheet restore too. - Drafts in the dose, note, blood pressure, symptom and bloodwork sheets, the compound picker's search, the date/time pickers and the site row use rememberSaveable; nullable values use a list saver so a cleared mood, hair or time stays cleared instead of re-running the initializer. - An explicit site choice is kept apart from the loaded suggestion, so history arriving after a restore no longer overrides it. SheetRestorationTest covers each sheet with StateRestorationTester.
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.
Rotating the phone (or any configuration change) closed whatever bottom sheet was open and threw away the draft. The open sheet (Today, Journal, item editor) and its fields are now rememberSaveable; sheet targets, LogTarget and Occurrence are @serializable and go through a small JSON saver, and the sheet content runs under its own SaveableStateHolder so the fields inside ModalBottomSheet restore too. Nullable values (mood, hair, picked time) use a list saver so a cleared value stays cleared, and an explicit site pick is kept apart from the loaded suggestion so late-arriving history doesn't override it.
SheetRestorationTest covers each sheet with StateRestorationTester. Rebased from the old fix/sheet-rotation branch (one import conflict in TodayScreen.kt); domain tests and the full foss unit run pass locally.