I have a ComposeView in a Fragment, that doesn't get it's state restored when from popping the back stack for a fragment transaction. I've tried using an XML with an id set on the ComposeView which normally would save view state for non-compose views. This is resetting my LazyColumn position to the top. I can work around it by having a LazyListState in the Fragment ViewModel. Having to save all view state in the VM to be restored when popping the back stack doesn't seem optimal. Am I doing something wrong?
I'll look into that. I made a test app that just did a fragment transaction and it does save the LazyColumn state. I'm losing the ComposeView state when using NavComponent to navigate to another view and popping back.
The default strategy is tied to the view being detached from the window, which makes it quite incompatible with how transitions and animators work (by detaching your view from the hierarchy and operating on an overlay containing those views)
So you should see the same issue if you use activity transitions; it isn't something fragment specific
1 year ago
I tried a transaction with an animation and it did save the ComposeView's state when popping.