'SwiftUI navigation bar inline mode searchable issue
I've noticed a pretty big issue when using inline
navigation bar display mode and searchable
on my List
in my app. When selecting the navigationlink it’s giving an undesired look when navigating to the view pushed. Using automatic
display mode works just fine, and I don't see the issue.
I'm not sure why this is happening with display mode inline only. I'd rather not use LargeTitle
's, I just dislike the look of them. Is this a bug or a mistake I'm making. I wrote reproducible code below, any help would be appreciated.
UPDATED APRIL 5, 2022
It's been two weeks since I reported the issue to Apple. I've been unable to find any kind of solutions or temporary workarounds besides use Xcode 13.2.1 which isn't a fix in any kind of way. If anyone has any tips please do comment.
It seems Xcode 13.3 is the issue, I downloaded Xcode 13.2.1 and it's working just fine. I've reported this issue. You can see the same code working fine on previous versions. So anything above iOS 15.2 is broken and doing the same.
Xcode 13.3 BUG
Xcode 13.2.1 Working
enum Test: String, CaseIterable, Identifiable {
case one
case two
case three
case four
var id: Self { self }
}
struct ContentView: View {
@State var search: String = ""
var body: some View {
NavigationView {
List(search.isEmpty ? Test.allCases : Test.allCases.filter{$0.rawValue.localizedCaseInsensitiveContains(search)}, id: \.self) { item in
NavigationLink(destination: Text(item.rawValue)) {
Text(item.rawValue)
}
}
.searchable(text: $search, placement: .navigationBarDrawer(displayMode: .always), prompt: "Search")
.navigationTitle("Searchable")
.navigationBarTitleDisplayMode(.inline)
}
}
}
Solution 1:[1]
I found a simple workaround, download Xcode 13.2.1. No bugs present when running it on iOS 15.4+. Compiling from an Xcode version before 13.3 seems to do the trick. I assumed I needed the latest version of Xcode for App Store submissions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | cole |