Fixed
Status Update
Comments
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 4043c16795c46b8a3bc915e1994bf9dccd2eeb15
Author: Jeremy Woods <jbwoods@google.com>
Date: Fri Dec 03 16:25:47 2021
Ensure Dialogs destination are properly restored
When there is a config change or process death while a dialog
destination is on top of the stack, NavHost is recomposed twice, once
after the initial restoration and again after the navController get to
the proper destination. During the first composition, NavHost calls
DialogHost and it has the entry associated with the dialog, but since
since the Lifecycle has not yet reached at least STARTED, the dialog is
not shown. On the second composition, the Lifecycle of the entry is
STARTED, but since we have already called the DialogHost function with
the dialogNavigator, we don't actually execute the function cause from
the perspective of compose, nothing has changed.
We should incorperate the concept of visible entries into DialogHost so
that navigation properly takes into account the changes in Lifecycle
states that determine the appropriate screen.
This also mean if you make a dialog your start destination, it will now
show properly.
RelNote: "Dialog destination are no properly restored on top of the
screen after config changes or process death."
Test: NavHostTest
Bug: 207386169
Change-Id: I4c0dce39bbbe26d05d0cb60c65c6e5fcfbbc62b2
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/DialogHost.kt
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
https://android-review.googlesource.com/1910016
Branch: androidx-main
commit 4043c16795c46b8a3bc915e1994bf9dccd2eeb15
Author: Jeremy Woods <jbwoods@google.com>
Date: Fri Dec 03 16:25:47 2021
Ensure Dialogs destination are properly restored
When there is a config change or process death while a dialog
destination is on top of the stack, NavHost is recomposed twice, once
after the initial restoration and again after the navController get to
the proper destination. During the first composition, NavHost calls
DialogHost and it has the entry associated with the dialog, but since
since the Lifecycle has not yet reached at least STARTED, the dialog is
not shown. On the second composition, the Lifecycle of the entry is
STARTED, but since we have already called the DialogHost function with
the dialogNavigator, we don't actually execute the function cause from
the perspective of compose, nothing has changed.
We should incorperate the concept of visible entries into DialogHost so
that navigation properly takes into account the changes in Lifecycle
states that determine the appropriate screen.
This also mean if you make a dialog your start destination, it will now
show properly.
RelNote: "Dialog destination are no properly restored on top of the
screen after config changes or process death."
Test: NavHostTest
Bug: 207386169
Change-Id: I4c0dce39bbbe26d05d0cb60c65c6e5fcfbbc62b2
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/DialogHost.kt
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
jb...@google.com <jb...@google.com> #3
This has been fixed internally and will be available in the Navigation 2.4.0-rc01
release.
le...@gmail.com <le...@gmail.com> #4
Awesome, thanks!
or...@gmail.com <or...@gmail.com> #5
i dont understand whats going on.... but i havent done anythong wrong to nobady... i belive i have been framed
Description
Component used: Navigation
Version used: 2.4.0-beta02
Devices/Android versions reproduced on: Emulator API 23 and 31
Describe the problem:
When navigating to a composable dialog destination, the dialog destination is lost after an orientation change.
Observed Results:
The composable dialog destination is lost after an orientation change
Expected Results:
The composable dialog destination should still be visible after an orientation change
Steps to reproduce:
dialog
Relevant Code:
The composable dialog is defined here:https://github.com/leinardi/Forlago/blob/dialog/modules/feature-foo/src/main/kotlin/com/leinardi/forlago/feature/foo/ui/foodialog/FooDialogScreen.kt#L36
The Dialog destination route is defined here:https://github.com/leinardi/Forlago/blob/dialog/modules/core-navigation/src/main/kotlin/com/leinardi/forlago/core/navigation/destination/foo/FooDialogDestination.kt#L22
The Dialog destinations are added to the NavHost here:https://github.com/leinardi/Forlago/blob/dialog/app/src/main/kotlin/com/leinardi/forlago/ui/MainActivity.kt#L109
Attached there is a short video showing the issue.