I am trying to fix an annoying issue here a list of navigation links will shift if the user taps on one of the links after scrolling down.
Notice how after I scroll down a bit and tap on item 60 - the entire list jumps down as the transition to the new view plays out.
This is the source to reproduce the issue. Note that it only happens after you've scrolled down a bit.
import SwiftUI
struct ContentView: View {
let items = generateItems()
var body: some View {
NavigationStack {
List(items, id: \.self) { item in
NavigationLink {
Text(item)
} label: {
Text(item)
}
}
.navigationTitle("Items")
}
}
}
#Preview {
ContentView()
}
func generateItems() -> [String] {
var items: [String] = []
for i in 1...1000 {
items.append("\(i)")
}
return items
}