Fixed
Status Update
Comments
jb...@google.com <jb...@google.com> #2
This is known, but as currently designed this is intentional. The NavHost
updates the displayed content based on the current state of the NavController
and it needs the first composition to update the state.
jb...@google.com <jb...@google.com> #3
Take that back we might be able to do it cause of some other changes we made a little bit ago.
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 2594b434a6b32cd99544b8df4cd959a4f4e82d22
Author: Jeremy Woods <jbwoods@google.com>
Date: Fri Oct 13 22:28:01 2023
Allow NavHost to display entries on first composition
Currently on the first composition the NavHost does not have an entry to
display and it has to wait for the next composition for the state to be
updated.
By rearranging the code, we can get a non-empty back stack on the first
composition.
RelNote: "NavHost will not render the start destination on the first
composition pass."
Test: all tests including preview pass
Bug: 304852206
Change-Id: I439a7fe894907b1ebee251134113acb08973083c
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
https://android-review.googlesource.com/2788438
Branch: androidx-main
commit 2594b434a6b32cd99544b8df4cd959a4f4e82d22
Author: Jeremy Woods <jbwoods@google.com>
Date: Fri Oct 13 22:28:01 2023
Allow NavHost to display entries on first composition
Currently on the first composition the NavHost does not have an entry to
display and it has to wait for the next composition for the state to be
updated.
By rearranging the code, we can get a non-empty back stack on the first
composition.
RelNote: "NavHost will not render the start destination on the first
composition pass."
Test: all tests including preview pass
Bug: 304852206
Change-Id: I439a7fe894907b1ebee251134113acb08973083c
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
jb...@google.com <jb...@google.com> #5
This has been fixed internally and will be available in the Navigation 2.7.5
release.
na...@google.com <na...@google.com> #6
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-compose:2.7.5
na...@google.com <na...@google.com> #7
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-compose:2.8.0-alpha01
Description
Component used: navigation-compose Version used: 2.7.4
Compose components are generally expected to be able to display themselves on the initial composition, without requiring a second composition.
Right now,
NavHost
doesn't follow this expectation: on the first composition,NavHost
won't display anything, and will only display a destination on the second and subsequent compositions. One additional consequence is that each nestedNavHost
will lose another frame until it resolves to display the current destination.This is sort of related to b/253654317 - the reason it works for
@Preview
now is from special handling whenLocalInspectionMode.current
istrue
. If it worked directly on the first composition pass, it should work in previews directly without needing theLocalInspectionMode.current
special handling.