ScrollView ScrollPosition scrollTo Anchor ignored/broken

ScrollPosition does not obey anchor when calling scrollTo.

The anchor is ignored and it does not matter what value you provide. If the view is below the visible content, it will pin the new scrolled to view at the bottom.

If the view is already in the visible content, it will not scroll to the anchor.

If the view is above the visible content, it will pin to top.

All three cases ignore the anchor.

This just another example of how painful SwiftUI is to work with. It just doesn't work as expected or intended, despite years of prioritizing ScrollView APIs. Link to Gist

 // This should scroll to item 50 with the requested anchor, but SCROLLPOSITION IGNORES THE ANCHOR.
    if shouldBeTopAnchor {
        // Expected: Scroll item 50 to top, but actually scrolls to bottom
        scrollPosition.scrollTo(id: 50, anchor: .top)
    } else {
        // Expected: Scroll item 50 to center, but actually scrolls to top
        scrollPosition.scrollTo(id: 50, anchor: .center)
    }
ScrollView ScrollPosition scrollTo Anchor ignored/broken
 
 
Q