Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resetRoot(saveState = true, restoreState = true) loses saveable state #1342

Closed
steelahhh opened this issue Apr 18, 2024 · 3 comments · Fixed by #1354
Closed

resetRoot(saveState = true, restoreState = true) loses saveable state #1342

steelahhh opened this issue Apr 18, 2024 · 3 comments · Fixed by #1354

Comments

@steelahhh
Copy link

This can be reproduced in chrisbanes/tivi:

  • open any show detail from discover
  • scroll down
  • select another tab
  • go back to discover

Backstack is restored properly, but any of the rememberSaveable (e.g. scroll) state is lost

I suppose this is expected with the current implementation, but is it possible to support this?

@chrisbanes
Copy link
Contributor

The PR linked above verifies the issue, but I'm not sure how to fix it tbh. At a high-level, we need to call performSave on our BackStackRecordLocalSaveableStateRegistry when the back stack entry is removed. Thus the saveable state is stored somewhere (where tbd).

@ZacSweers this might be one for you, as you wrote most of BackStackRecordLocalSaveableStateRegistry by the look of it.

@TepesLucian
Copy link

Any workarounds till this gets fixed like saving states in presenters?

@chrisbanes
Copy link
Contributor

FYI, #1354 now contains a fix

github-merge-queue bot pushed a commit that referenced this issue May 27, 2024
…ents (#1354)

This PR migrates `NavigableCircuitContent` to use `SaveableStateHolder`,
rather than our hand-rolled
`SaveableStateRegistryBackStackRecordLocalProvider`.

I don't know the history behind
`SaveableStateRegistryBackStackRecordLocalProvider`, but
`SaveableStateHolder` is the first party solution for this. It is used
by AndroidX Navigation, so we can assume it is well tested.

This PR relies on a bunch of `movableContent` fixes added in #1282 (I
had to add a similar one in this PR for
`CupertinoGestureNavigationDecoration`).

Fixes #1342
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 a pull request may close this issue.

3 participants