Keep user at the current scroll position when elements in ForEach loop update swiftui

Viewed 568

I'm working on a project in SwiftUI and have a forEach loop, something like this:

ForEach(self.items, id: \.self) { item in
    Text(item)
        .padding(4)
}

and when I update self.items the ForEach view updates, but it also forces the scroll position back to the very top. Is there a way I could get the ForEach view to update and add the items without changing the current scroll position the user was at?

Any help with this matter would be appreciated. Also, I would prefer a non-iOS 14 method, since I'm working on an application to be released soon and don't expect it to be compatible with iOS 14.

0 Answers
Related