BrendanS
BrendanS

Reputation: 331

Use of Section header and searchable causes bug?

I have in my code a Form which contains multiple conditional sections.

I want the form to be searchable ONLY if one section is included.

if myCondition {
   Section {
      Text("My Section Contents")
   } header: {
      Text("My Section Header")
   }.searchable(text: $filterText, placement: .navigationBarBrawer(displaymode: .always))
}

This however seems to break the header which renders normally without the searchable.

Any ideas? Is there another way to conditionally include the search bar?

Thanks in advance.

enter image description here

Upvotes: 0

Views: 122

Answers (1)

ChrisR
ChrisR

Reputation: 12125

            if canSearch {
                Section {
                    Text("Now you can search")
                        .searchable(text: $filterText, placement: .navigationBarDrawer(displayMode: .always))
                } header: {
                    Text("Search")
                }
            }

Upvotes: 1

Related Questions