The issue
After I populate a LazyVStack
with gadgets of various heights, the ScrollView
round it doesn’t behave as anticipated on macOS 13. This simplified instance continues to be considerably usable, however as you may see within the display recording (I am scrolling very slowly), the scroll place jumps round. In my manufacturing app this habits will get a lot worse, making it generally not possible to scroll upwards once more.
Code
struct ContentView: View {
var physique: some View {
ScrollView {
LazyVStack {
ForEach(1...40, id: .self) { worth in
Merchandise(worth: worth)
.id(worth)
.padding()
}
}
.padding()
}
.body(width: 300, top: 300)
}
}
struct Merchandise: View {
let worth: Int
let lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim advert minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
var physique: some View {
if worth < 20 {
Textual content("(worth) A protracted textual content: (lorem)")
}
else {
Textual content("(worth) A brief textual content")
}
}
}
iOS vs. macOS
I’ve discovered this submit concerning the identical concern on iOS. I additionally ran my code on iOS and whereas the scroll indicator adjustments its top (which might point out a change in content material dimension), the scrolling was clean with out jumps of the scroll place.
Query
Has anybody had the identical concern and located a option to make this work? The instance would simply work with a daily VStack
, however I would like to make use of LazyVStack
for efficiency causes and the power so as to add a sticky header.