Open sescandell opened 8 years ago
A Workaround I found (I think working for most cases) is to update the BackButtonPressed
method with the following:
public override void OnBackPressed()
{
if (SupportFragmentManager.BackStackEntryCount >= 1)
{
// MODIFICATION HERE: go back over all fragments with the same tag
var lastFragment = 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?
var currentFragsInfo = 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.
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 updateCachedFragment
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.