accompanist icon indicating copy to clipboard operation
accompanist copied to clipboard

[Navigation Material] Nested NavHost on bottomSheet(route=) causes sheet to dismiss

Open chrisagay opened this issue 3 years ago • 2 comments

I have a request to build a bottom sheet with series of navigation. Originally I tried to create a nested NavGraph but that did not allow all the navigations to share the bottom sheet. I then switched to using a NavHost defined in the bottomSheet(route=) composable. This feature does work with Navigation 2.4.2/2.5.0-alpha03, but the visibleEntries update(s) to 2.5.0-alpha04 causes the sheet to instantly hide when it navigates to the startDestination of the nested NavHost.

Steps to reproduce

  1. Create a basic application with a ModalBottomSheetLayout just like the example on the Navigation Material page.
  2. Add a bottom navigation bar with its own NavHost to control navigation when clicking the nav buttons
  3. Set one button to navigate to a bottomSheet(route=) destination defined in the NavGraphBuilder of #1.
  4. In the composable content of the bottom sheet create a NavHost with a start destination.
  5. 4(a) more explicitly for my case, my route for the bottomSheet() and the start destination of the nested NavHost were the same
  6. Run app, click the nav button that should open the bottom sheet

Expected behavior Bottom Sheet should not hide when navigating to the NavHost

Additional context I don't think this is necessarily a full issue, likely I am using the APIs incorrectly. If you can inform me about something I am doing incorrectly to resolve this so I can update the project to the most recent Navigation library would be most appreciated

chrisagay avatar Jun 30 '22 00:06 chrisagay

Sorry for bugging you guys about this. It was definitely related to 4(a), assigning the route of the bottom sheet and the start destination of the NavHost to the same value. I resolved this by adding a dummy route as the start destination, created a new local NavHostController and using that to navigate to the view I wanted displayed. Feel free to close this unless you think there is something to look further into.

chrisagay avatar Jul 01 '22 20:07 chrisagay

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 Aug 01 '22 03:08 github-actions[bot]