Mutevu
Mutevu

Reputation: 303

navigateUp() and popBackStack() not working. Instead, they reload the current fragment

I am trying to navigate up the backstack. On calling the method view?.findNavController().navigateUp() and logging the destination using view?.findNavController().getCurrentDestination(), I see the function popping the current destination and then reloading it again. I don't understand why this could be happening yet I am doing the same in other fragments and it's working.

Upvotes: 2

Views: 1351

Answers (1)

Mutevu
Mutevu

Reputation: 303

The issue came up because I was using LiveData to trigger the navigation. To avoid the issue, I have had to update the MutableLiveData before navigating so that it does not request to navigate back when I navigateUp from the destination.

Upvotes: 5

Related Questions