accompanist icon indicating copy to clipboard operation
accompanist copied to clipboard

[Navigation Material] bottomSheet() destination does not get updated values

Open chriswiesner opened this issue 2 years ago • 14 comments

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?

!(bug)

!(working fine)

Environment:

  • Android OS version: Android 12
  • Device: Emulator
  • Accompanist version: 0.23.1

chriswiesner avatar Mar 22 '22 10:03 chriswiesner

Whoo, this one is interesting. I will investigate and get back to you this week!

jossiwolf avatar Mar 28 '22 16:03 jossiwolf

Hey @jossiwolf Any update on that?

chriswiesner avatar Apr 06 '22 07:04 chriswiesner

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!

jossiwolf avatar Apr 06 '22 13:04 jossiwolf

Thanks for investigating! (Sadly this might imply that there is no fix in the near future :/ )

chriswiesner avatar Apr 06 '22 15:04 chriswiesner

@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(...)
    ...
}

jossiwolf avatar Apr 06 '22 18:04 jossiwolf

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

chriswiesner avatar Apr 08 '22 13:04 chriswiesner

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.

github-actions[bot] avatar May 09 '22 03:05 github-actions[bot]

@jossiwolf did you manage to file an issue on google side?

chriswiesner avatar May 09 '22 05:05 chriswiesner

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.

github-actions[bot] avatar Jun 09 '22 03:06 github-actions[bot]

Still seems to be an issue in Accompanist 0.24.10-beta

okycelt avatar Jun 12 '22 01:06 okycelt

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.

github-actions[bot] avatar Jul 12 '22 03:07 github-actions[bot]

seems the issue is still not resolved :/

chriswiesner avatar Aug 12 '22 12:08 chriswiesner

@jbw0033 Do you mind taking another look at this? It's been a bit and I didn't make good progress with my investigation :)

jossiwolf avatar Sep 23 '22 16:09 jossiwolf

+1 on this, any ideas on fix plan on workaround?

anhanh11001 avatar Oct 20 '23 11:10 anhanh11001

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.

ianhanniballake avatar Mar 08 '24 06:03 ianhanniballake