Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear stack fail with fragmentHideStrategy = DETACH_ON_NAVIGATE_HIDE_ON_SWITCH #233

Open
VuHongKy opened this issue May 12, 2020 · 0 comments

Comments

@VuHongKy
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant