When adding to or removing from an array, the view does not update unless the user interacts with the ScrollView.
The Model is a ObservableObject that is declared as a StateObject early in the app lifecycle and then passed as a EnvironmentObject.
The data is simply a custom Profile object with an array of objects, when adding to store.profile!.tasks.append() or removing from the view does not update unless the user scrolls the ScrollView; I mean literally by 1 pixel.
What I have tried
- Wrapping the ForEach in a LazyVStack or VStack
- Wrapping the NavigationLink in a VStack
- Making sure size is full height incase it needed to recalculate
Code
class Profile: Identifiable, Codable, Equatable var tasks: [Task] } struct Task: Identifiable, Codable, Equatable { var createdBy: String var title: String var date: Date } class Store : ObservableObject { @Published var profile: Profile? } struct ListView: View { @EnvironmentObject var store: Store var body: some View { GeometryReader { geometry in ZStack(alignment: .bottomTrailing) { ScrollView(.vertical, showsIndicators: false){ ForEach(store.profile!.tasks.filter({ return $0.createdBy == store.profile!.uid}).indices, id: \.self) { index in NavigationLink(destination: DetailView().environmentObject(store)) { TasksRow().id(UUID()) } } } .frame(maxWidth: geometry.size.width, alignment: .center) .frame(maxHeight: geometry.size.height) .background(Color.gray) } } }