fix(bottom-navigation): fragment handling (#9244)

This commit is contained in:
Igor Randjelovic
2021-02-25 02:35:16 +01:00
committed by GitHub
parent e7951b320f
commit c8ef6f2ab3

View File

@@ -540,7 +540,9 @@ export class BottomNavigation extends TabNavigationBase {
if (fragment != null) { if (fragment != null) {
fragment.setMenuVisibility(true); fragment.setMenuVisibility(true);
fragment.setUserVisibleHint(true); // commenting out as it fixes rare crash when going
// back from deeply nested/modally shown fragments
// fragment.setUserVisibleHint(true);
} }
this._currentFragment = fragment; this._currentFragment = fragment;
@@ -581,8 +583,8 @@ export class BottomNavigation extends TabNavigationBase {
fragmentExitTransition.setResetOnTransitionEnd(true); fragmentExitTransition.setResetOnTransitionEnd(true);
} }
if (fragment && fragment.isAdded() && !fragment.isRemoving()) { if (fragment && fragment.isAdded() && !fragment.isRemoving()) {
const pfm = (<any>fragment).getParentFragmentManager ? (<any>fragment).getParentFragmentManager() : null; const pfm = (<any>fragment).getParentFragmentManager ? (<any>fragment).getParentFragmentManager() : fragmentManager;
if (pfm && !pfm.isDestroyed()) { if (pfm) {
try { try {
if (pfm.isStateSaved()) { if (pfm.isStateSaved()) {
pfm.beginTransaction().remove(fragment).commitNowAllowingStateLoss(); pfm.beginTransaction().remove(fragment).commitNowAllowingStateLoss();