You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner. It is now read-only.
Create an app with only one VM and a fragment to display it (suppose the VM has one property ID)
From the fragment, create a Command to navigate to the same VM but with a different "criteria" (imagine navigating to a same object but with a different ID)
Follow the navigation:
Launch the app
Display the VM with ID 1
From this fragment, click on the button to navigate to the VM with ID 2
Press the back button
Press the button to navigate to the VM with ID 2
Expected behavior
The fragment with ViewModel ID 2 should be displayed
Actual behavior
Nothing happens
Origin of the issue
The ShouldReplaceCurrentFragment returns FragmentReplaceMode.NoReplace.
This is because when navigating to VM with ID 2, ShowFragment set the fragInfo.CachedFragment with informations about VM with ID 2. When we click on the back button, we so display back the VM with ID 1.
Then if we click again on the button to display VM with ID 2, the fragment's tag to display is the same as the one currently displayed but with informations from VM ID 2 (pressing the back button didn't update CachedFragment object in "currentFragInfo").
Keep it simple, issue is the cached Fragment is not updated on BackButton pressed if going back to a fragment with the same tag.
The text was updated successfully, but these errors were encountered:
A Workaround I found (I think working for most cases) is to update the BackButtonPressed method with the following:
publicoverridevoidOnBackPressed(){if(SupportFragmentManager.BackStackEntryCount>=1){// MODIFICATION HERE: go back over all fragments with the same tagvarlastFragment=GetLastFragmentInfo();SupportFragmentManager.PopBackStackImmediate(lastFragment.Tag,(int)PopBackStackFlags.Inclusive);if(FragmentCacheConfiguration.EnableOnFragmentPoppedCallback){//NOTE(vvolkgang) this is returning ALL the frags. Should we return only the visible ones?varcurrentFragsInfo=GetCurrentCacheableFragmentsInfo();OnFragmentPopped(currentFragsInfo);}return;}base.OnBackPressed();}
This imply that if you navigate to the same fragment with different parameters, pressing the back button will redirect the user over all its navigation on that fragment (something acceptable for my context). Don't know what would be the situation if there is actually only one fragment for all the application.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Steps to reproduce
Expected behavior
The fragment with ViewModel ID 2 should be displayed
Actual behavior
Nothing happens
Origin of the issue
The
ShouldReplaceCurrentFragment
returnsFragmentReplaceMode.NoReplace
.This is because when navigating to VM with ID 2,
ShowFragment
set thefragInfo.CachedFragment
with informations about VM with ID 2. When we click on the back button, we so display back the VM with ID 1.Then if we click again on the button to display VM with ID 2, the fragment's tag to display is the same as the one currently displayed but with informations from VM ID 2 (pressing the back button didn't update
CachedFragment
object in "currentFragInfo").Keep it simple, issue is the cached Fragment is not updated on BackButton pressed if going back to a fragment with the same tag.
The text was updated successfully, but these errors were encountered: