DiegoMod1
DiegoMod1

Reputation: 46

toolbar(.hidden) not working when navigate while searching is active

Well Im just creating a personal project and then I face this bug. My navigation looks like this, if you compile the code and then try to navigate while you are not searching the .toolbar(.hidden) is working fine but when you search for example letter "D" you filter Diego, Daniel then if you navigate you will see ``.toolbar(.hidden)` is completely ignored. The expected behaviour is to follow the modifier in both cases while searching or not.

Struct ContentView: View {

    @State var searchedText = ""
    var names = ["Diego", "Jake", "Pablo", "Michael", "Hugo", "Roberth", "Daniel", "Rodrigo"]
    var filterednames: [String] {
        if searchedText != "" {
            return names.filter { $0.lowercased().contains(searchedText.lowercased()) }
        } else {
            return names
        }

    }

    var body: some View {
        NavigationStack {
            List(content: {
                    ForEach(filterednames, id: \.self) { name in
            
                        NavigationLink(value: name) {
                            Text(name)
                                .font(.title2)
                        }
                }

            })
            .navigationDestination(for: String.self) { name in
                Text(name)
                    .toolbar(.hidden)
            }
            .searchable(text: $searchedText)
        }
    }
}

Upvotes: 1

Views: 69

Answers (0)

Related Questions