As title said, I set up Fragnav with this option:
fragNavController.fragmentHideStrategy = FragNavController.DETACH_ON_NAVIGATE_HIDE_ON_SWITCH
Currently, I am on first bottom tab (Home) and try to pop all other stack to root fragment like this:
override fun popToRootFragment(tabIndex: Int?) {
// Not works if tabIndex is not belong this current stack
navController?.let {
val stackIndex = tabIndex?.valid() ?: it.currentStackIndex
it.clearStack(stackIndex)
}
}
override fun popAllToRootFragment() {
repeat(numberOfRootFragments) {
popToRootFragment(it)
}
}
And after that, I click on other bottom tab, for example, MyPage -> it just show blank page.
I checked library core code, and saw that when clear stack with stackIndex = 2 (MyPage), this function addPreviousFragment() not add MyPageFragment, but try to add HomeFragment (root fragment of current stack). -> so when click on MyPage bottom tab after that, it show blank page, because all fragments of MyPage stack's removed and MyPageFragment be not attached yet. And I used fragmentHideStrategy = DETACH_ON_NAVIGATE_HIDE_ON_SWITCH, means just show fragment when switch tab.
This bug just happened with fragNavController.fragmentHideStrategy = FragNavController.DETACH_ON_NAVIGATE_HIDE_ON_SWITCH, but it works with DETACH or HIDE strategy.
Do you think this is the library bug? Or am I wrong? Please check it and fix it as soos as possible. Thank you so much!
As title said, I set up Fragnav with this option:
fragNavController.fragmentHideStrategy = FragNavController.DETACH_ON_NAVIGATE_HIDE_ON_SWITCH
Currently, I am on first bottom tab (Home) and try to pop all other stack to root fragment like this:
And after that, I click on other bottom tab, for example, MyPage -> it just show blank page.
I checked library core code, and saw that when clear stack with stackIndex = 2 (MyPage), this function addPreviousFragment() not add MyPageFragment, but try to add HomeFragment (root fragment of current stack). -> so when click on MyPage bottom tab after that, it show blank page, because all fragments of MyPage stack's removed and MyPageFragment be not attached yet. And I used fragmentHideStrategy = DETACH_ON_NAVIGATE_HIDE_ON_SWITCH, means just show fragment when switch tab.
This bug just happened with fragNavController.fragmentHideStrategy = FragNavController.DETACH_ON_NAVIGATE_HIDE_ON_SWITCH, but it works with DETACH or HIDE strategy. Do you think this is the library bug? Or am I wrong? Please check it and fix it as soos as possible. Thank you so much!