accompanist
accompanist copied to clipboard
[Navigation Material] bottomSheet() destination does not get updated values
Describe the bug
bottomSheet()
-Destination composable does not get updated data from inheriting composable.
if i use a composable()
destination it works fine.
To Reproduce
See gist here. https://gist.github.com/chriswiesner/6503999979f67f8fcca33c56a961c245
Expected behavior
bottomSheet()
composable also gets updated data
Screenshots?
Environment:
- Android OS version: Android 12
- Device: Emulator
- Accompanist version: 0.23.1
Whoo, this one is interesting. I will investigate and get back to you this week!
Hey @jossiwolf Any update on that?
Hi, it looks like this is a Navigation and/or Compose Runtime bug. I was able to repro without any Accompanist dependencies and am currently working on finding a minimal repro. I will post the link to the issue to follow along once I filed it!
Thanks for investigating! (Sadly this might imply that there is no fix in the near future :/ )
@chriswiesner In the meantime, I would recommend passing the State
object instead of the value itself. Not as nice, but it works as a workaround:
class MyViewModel: ViewModel() {
val viewState = mutableStateOf(...)
...
}
while that solved the issue in the sample i still have problems in my production code. dug a bit and found an issue.
RootNav
- rootScreen
- DetailScreen(MyViewModel())
-- detail home
-- bottomSheet
i have nested navigation. creating the VM when navigating to the Detailscreen - (not ideal, i know)
if I use a bottomSheet{}
destination in the detail screen it somehow triggers a recomposition in the root, resulting in two different VM instances (bottom sheet gets a different VM than the Detail screen home)
if I use composable {}
destination in the detail screen everything works fine.
Example Gist: https://gist.github.com/chriswiesner/ab2c99f78d34406cd3c52a45108de8ee
/edit: remembering the VM does the trick though
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
@jossiwolf did you manage to file an issue on google side?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Still seems to be an issue in Accompanist 0.24.10-beta
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
seems the issue is still not resolved :/
@jbw0033 Do you mind taking another look at this? It's been a bit and I didn't make good progress with my investigation :)
+1 on this, any ideas on fix plan on workaround?
With the release of Compose Material 1.7.0-alpha04, the Material team has added a new artifact: androidx.compose.material:material-navigation
, which fully replaces Accompanist Navigation Material.
As such, we are closing all issues here on Accompanist and will be fully deprecating Accompanist Navigation Material in an upcoming release.
A number of issues were fixed as part of the migration, but if you're still seeing an issue, please file an issue with a sample project that reproduces your issue and the Material team will take a look.