Skip to content

Sheets: keep open sheets and their drafts across rotation - #35

Open
ApolloF wants to merge 1 commit into
mainfrom
fix/sheet-rotation-rebased
Open

ApolloF wants to merge 1 commit into
mainfrom
fix/sheet-rotation-rebased

Conversation

@ApolloF

@ApolloF ApolloF commented Nov 1, 2026

Copy link
Copy Markdown
Owner

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.

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.
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