SwiftUI `searchable` results in jumpy animation when used with `ScrollView`

Viewed 65

When putting a ScrollView inside a NavigationView, that uses the searchable view modifier, focusing and unfocusing the search bar causes the ScrollView to jump immediately instead of smoothly animating as a List view would do.

recording showing the jumpy animation

The code below produces the behaviour in the GIF above.

struct TestView: View {
    @State
    private var term = ""
    var body: some View {
        NavigationView {
            ScrollView {
                VStack {
                    Text("Bar")
                    Text("Baz")
                }
            }
            .navigationTitle("Foo")
        }
        .searchable(text: $term)
    }
}

This seems like a SwiftUI bug to me? Is there any workaround?

0 Answers
Related