Created
August 29, 2022 14:41
-
-
Save atrinh0/968e0d39f02bcfda6e92815cf9a7a773 to your computer and use it in GitHub Desktop.
ScrollViewReader scrollTo crash on Xcode 14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@State private var items: [RandomItem] = (0...25).indices.map { _ in RandomItem() } | |
var body: some View { | |
ScrollViewReader { proxy in | |
List { | |
ForEach(items) { item in | |
Text("\(item.number)") | |
.id(item.id) | |
} | |
} | |
.onChange(of: items.count) { _ in | |
withAnimation { | |
proxy.scrollTo(items.last?.id) | |
} | |
} | |
Button { | |
items.append(RandomItem()) | |
} label: { | |
Text("Add item") | |
} | |
} | |
} | |
} | |
struct RandomItem: Identifiable { | |
var id = UUID() | |
let number = Int.random(in: 0...100) | |
} |
Raised FB11402625
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behaviour, scroll to last item works on Xcode 13.4.1.
Simulator.Screen.Recording.-.iPhone.13.Pro.Max.-.2022-08-29.at.15.42.34.mp4