Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Do you have sample project that reproduces your issue (where hitting back from B doesn't show the dialog D again)?
mu...@gmail.com <mu...@gmail.com> #3
Here is the sample project that reflects the issue. https://github.com/musooff/android-architecture-components/tree/master/NavigationAdvancedSample
As in the gif file, the behavior that I am getting is B showing below D instead of going to completely new screen that just shows B.
As in the gif file, the behavior that I am getting is B showing below D instead of going to completely new screen that just shows B.
d....@gmail.com <d....@gmail.com> #4
I'm experiencing same behavior with 2.1.0-alpha05.
an...@gmail.com <an...@gmail.com> #5
Hello team,
I am also facing the similar issue(https://github.com/andor201995/NoteIt/pull/15 )
I am using nav_version: 2.1.0-alpha05
Device: Samsung galaxy S8+
Expected Result:
I have a dialog AddNewNoteFragment on top of a fragment NoteListingFragment and move to a fragment UpdateNoteBodyFragment from a button on AddNewNoteFragment(Dialog), the screen should show UpdateNoteBodyFragment. And when I pop back from UpdateNoteBodyFragment, it should go to previous stage of AddNewNoteFragment on top of NoteListingFragment.
Current Result:
When i trigger actionAddNewNoteFragmentToUpdateNoteBodyFragment then dialog is not dismissed and AddNewNoteFragment(dialog) is on top of UpdateNoteBodyFragment(while dialog should get dismissed) and when i dismiss the AddNewNoteFragment(dialog) then UpdateNoteBodyFragment also get's destroyed and return's back to NoteListingFragment(start point).
And now if i click on any button to trigger a navigation action then i get a crash.
java.lang.IllegalArgumentException: navigation destination com.andor.navigate.notepad:id/action_noteListingFragment_to_addNewNoteFragment is unknown to this NavController
at androidx.navigation.NavController.navigate(NavController.java:786)
at androidx.navigation.NavController.navigate(NavController.java:727)
at androidx.navigation.NavController.navigate(NavController.java:713)
at androidx.navigation.NavController.navigate(NavController.java:701)
at com.andor.navigate.notepad.listing.fragment.NoteListingFragment.onOptionsItemSelected(NoteListingFragment.kt:180)
attaching the video file
I am also facing the similar issue(
I am using nav_version: 2.1.0-alpha05
Device: Samsung galaxy S8+
Expected Result:
I have a dialog AddNewNoteFragment on top of a fragment NoteListingFragment and move to a fragment UpdateNoteBodyFragment from a button on AddNewNoteFragment(Dialog), the screen should show UpdateNoteBodyFragment. And when I pop back from UpdateNoteBodyFragment, it should go to previous stage of AddNewNoteFragment on top of NoteListingFragment.
Current Result:
When i trigger actionAddNewNoteFragmentToUpdateNoteBodyFragment then dialog is not dismissed and AddNewNoteFragment(dialog) is on top of UpdateNoteBodyFragment(while dialog should get dismissed) and when i dismiss the AddNewNoteFragment(dialog) then UpdateNoteBodyFragment also get's destroyed and return's back to NoteListingFragment(start point).
And now if i click on any button to trigger a navigation action then i get a crash.
java.lang.IllegalArgumentException: navigation destination com.andor.navigate.notepad:id/action_noteListingFragment_to_addNewNoteFragment is unknown to this NavController
at androidx.navigation.NavController.navigate(NavController.java:786)
at androidx.navigation.NavController.navigate(NavController.java:727)
at androidx.navigation.NavController.navigate(NavController.java:713)
at androidx.navigation.NavController.navigate(NavController.java:701)
at com.andor.navigate.notepad.listing.fragment.NoteListingFragment.onOptionsItemSelected(NoteListingFragment.kt:180)
attaching the video file
an...@gmail.com <an...@gmail.com> #6
Tested on google PixelXL(API 29) also same issue so it's not device specific.
il...@google.com <il...@google.com> #7
There's a couple of problems here relating to how Dialogs and Fragments work:
1. Dialogs are separate windows that always sit above your activity's window. This means that the dialog will continue to intercept the system back button no matter what state the underlying FragmentManager is in or what FragmentTransactions you do.
2. Operations on the fragment container (i.e., your normal <fragment> destinations) don't affect dialog fragments. Same if you do FragmentTransactions on a nested FragmentManager.
The initial release of Navigation's <dialog> support did not take these limitations into account and would treat dialog destinations just like any other in that, from Navigation's point of view, they could be put on the back stack and treated like any other <fragment> destination.
As that's not actually the case, we've made a few changes for Navigation 2.1.0-alpha06 to ensure that Navigation's state of the world matches what you actually see on the screen and prevent crashes like that in comment#5 .
The summary of this is that <dialog> destinations are now automatically popped when navigate to a non-dialog and non-activity destination, such as a <fragment> destination. For reference, this was done inhttps://android-review.googlesource.com/996359 and https://android-review.googlesource.com/1007662
1. Dialogs are separate windows that always sit above your activity's window. This means that the dialog will continue to intercept the system back button no matter what state the underlying FragmentManager is in or what FragmentTransactions you do.
2. Operations on the fragment container (i.e., your normal <fragment> destinations) don't affect dialog fragments. Same if you do FragmentTransactions on a nested FragmentManager.
The initial release of Navigation's <dialog> support did not take these limitations into account and would treat dialog destinations just like any other in that, from Navigation's point of view, they could be put on the back stack and treated like any other <fragment> destination.
As that's not actually the case, we've made a few changes for Navigation 2.1.0-alpha06 to ensure that Navigation's state of the world matches what you actually see on the screen and prevent crashes like that in
The summary of this is that <dialog> destinations are now automatically popped when navigate to a non-dialog and non-activity destination, such as a <fragment> destination. For reference, this was done in
j....@gmail.com <j....@gmail.com> #8
So what I can do to show the dialog again when the user press back on the fragment?
[Deleted User] <[Deleted User]> #9
So what I can do to show the dialog again when the user press back on the fragment?
Is this still not possible?
ar...@gmail.com <ar...@gmail.com> #10
So, what you suggest to do for this case? Are there alternative solutions?
il...@google.com <il...@google.com> #11
Dialog destinations cannot be put on the back stack, that's still and will always be the case.
gu...@gmail.com <gu...@gmail.com> #12
I think the only solution at present is to make fragment B a full dialog
Description
Version used: 2.1.0-alpha04
Devices/Android versions reproduced on: S10
I am trying to navigation from DialogFragment to Fragment in Navigation Component, but getting weird result.
When I navigate from DialogFragment to Fragment, background fragment is changing to target fragment with current dialog on top of it, instead of just moving to target fragment. Why I am getting this behavior or how to fix it?
By fixing I mean normal dialog behavior. Say, I have a dialog D on top of a fragment A and move to a fragment B from a button on D, the screen should show B. And when I pop back from B, it should go to previous stage of D on top of A.
Here is the navigation graph.
<navigation
xmlns:android="
xmlns:app="
xmlns:tools="
android:id="@+id/home"
app:startDestination="@+id/titleScreen">
<fragment
android:id="@+id/titleScreen"
android:name="com.example.android.navigationadvancedsample.homescreen.Title"
android:label="@string/title_home"
tools:layout="@layout/fragment_title">
<action
android:id="@+id/action_title_to_about"
app:destination="@id/aboutScreen"/>
</fragment>
<dialog
android:id="@+id/aboutScreen"
android:name="com.example.android.navigationadvancedsample.homescreen.About"
android:label="@string/title_about"
tools:layout="@layout/fragment_about">
<action
android:id="@+id/action_aboutScreen_to_register"
app:destination="@id/register" />
</dialog>
<fragment
android:id="@+id/register"
android:name="com.example.android.navigationadvancedsample.formscreen.Register"
android:label="fragment_leaderboard"
tools:layout="@layout/fragment_leaderboard" />
</navigation>
If this is a bug in the library, we would appreciate if you could attach:
- Sample project to trigger the issue.
- A screenrecord or screenshots showing the issue (if UI related).