SwiftUI scrollTo function stops working if I also use onScrollVisibilityChange

If I use scrollTo on its own, it works fine (actually not fine, it often scrolls to the wrong place with LazyVStack, but thats another topic)

However, if I also want to use onScrollVisibilityChange on one of my items in my ForEach and if I do, it just stops working. Everything still fires, but nothing scrolls.

This is on the latest macOS, and iOS.

WHY? How can I fix this?

You can find more details at https://stackoverflow.com/questions/79391208/swiftui-scrollto-function-stops-working-if-i-also-use-onscrollvisibilitychange

well..... I just answered my own question.

The .id MUST come after the .onScrollVisibilityChange

but why? its not logical at all. I understand how the nesting of view modifiers works, but why is the .id nullified if its before the other modifier?

SwiftUI scrollTo function stops working if I also use onScrollVisibilityChange
 
 
Q