Hidden navigation bar shows up after showing modal in detail screen
Hello, I found an interesting behavior in my project, I've spending a lot of time figuring out the root cause but I'm still unable to, posting here to determine if this is a bug or not.
- I have a
TabCoordinatableinside of aNavigationCoordinatable - I set the navigationBarHidden = true and set navigation title properly (for the back button title)
- I then push to a detail view, push to one layer deeper
- Then show a modal
- Manually navigate back to the TabView
- Issue: The originally hidden navigation bar appeared, after switching tabs it hides again
Here is a video of the issue that demonstrate the issue:
https://user-images.githubusercontent.com/10422762/156937516-f28e19f4-8afc-46c5-a8bb-68dad1617cae.mov
This is an example project that will repro the issue in the video: stinsen-example.zip
Hi! Sorry for the late answer. I have a branch navbarless. Can you try that and see if it solves your issue?
That does not solve my issue. I'm actually thinking this is a SwiftUI bug since I've been testing with an example without using Stinsen at all, I use TabView and NavigationView and NavigationLink to replicate the same situation, couldn't get it to work nither.
It seems to me that SwiftUI does not work well when you put TabView inside of a NavigationView.
I might found a solution but not entirely understand the rationale under it, I was looking at this answer https://stackoverflow.com/a/57518324/7904148, then I added .navigationTitle("") to the root views under each tab, .navigationBarHidden(true) was kept for sure, then the problem seems solved magically. 🤭
I'm not surprised that it worked - the navigationTitle modifier would force it to render a navigation bar and then apply the navigationBarHidden modifier as you originally expected. Not correct, definitely file a Feedback issue for the SwiftUI team. They are responsive, especially when you are able to provide an example like this one without any dependencies and an explanation of known workaround.