This question is similar to this question asked by someone else, but I wasn't satisfied by the answer posted there so I'd like to ask it again.
My specific use case is that I'm using a NavHost to navigate between screens in my app, and I made a custom navigation menu with buttons to navigate between screens. When switching between screens, I don't want the menu to leave the composition and then return, as this interrupts an animation I added to the menu and generally looks bad. However, there are some screens in my app that should not include the menu, and when switching to one of those screens the menu should fade out with the same animation as the rest of the screen (and fade back in when switching back to a screen that displays the menu).
As far as I can tell, this behavior of allowing certain composables to persist through specific navigation routes isn't a feature of NavHost, but I'm wondering if there are any generally accepted ways of accomplishing this. As far as the answer in the other question I linked to, which suggested using a 'when' statement instead of a NavHost, this seems to negate the entire point of the NavHost which is to save the backstack.