I'm using navigation graph to navigate between fragments and I noticed that my viewModel is cleared (onCleared) only when I press the back button, but not when I navigating to another fragment using this code:
val action = MyFragmentDirections.actionMyFragmentToParentFragment()
val navController = findNavController()
navController.navigate(action)
In the logs I see that the fragment onDestroyView() is called but the viewModel's onCleared() is not called.
What am I'm missing?