Hi,
I have a list with section headers as pinned views.
I'm trying to programmatically scroll to a view inside a section using a proxy.scrollTo(id, anchor: .top).
I was expecting the view to be aligned to the top of the scroll view but after the pinned header. Instead, it's aligned to the top of the scroll view overlapping with the header, hiding most of the row.
Here is a code snippet to reproduce:
import SwiftUI
struct ContentView: View {
var body: some View {
ScrollViewReader { proxy in
ScrollView {
LazyVStack(
pinnedViews: .sectionHeaders
){
ForEach(1...10, id: \.self) { count1 in
Section(content: {
Text("First row")
.id("\(count1), row1")
Text("second row")
Text("third row")
}, header: {
Text("Section \(count1)").font(.title)
.background(.red)
})
}
}
}
.safeAreaInset(edge: .bottom) {
Button("Tap me") {
proxy.scrollTo("3, row1", anchor: .top)
}
.padding()
}
}
}
}
Any idea how this could be solved?