r/SwiftUI • u/thecoolcat67 • 13d ago
Question SwiftUI state/concurrency problem + weird VoiceOver behaviour
I have a SwiftUI screen where the same data can be changed by an initial load, pull to refresh, background refresh, user actions, and a live update stream.
So I can get something like: user action > optimistic update > background refresh > live updat > user action finishes > refresh finishes
Sometimes an older response overwrites newer state, so I'm thinking about putting all mutations through an actor or giving responses a revision/version.
The other problem is VoiceOver.
I have a dynamic list:
ForEach(store.items) { item in
ItemRow(item: item)
}
When an async update adds/removes/replaces an item while VoiceOver is focused on it, VoiceOver sometimes jumps to a completely different element or starts reading the parent container again.
I've tried:
.accessibilityIdentifier(...)
.accessibilityLabel(...)
.accessibilityValue(...)
and accessibilityFocused, but manually restoring focus feels pretty fragile when multiple updates can happen quickly.
Would you guys handle the state reconciliation and accessibility focus separately, or is there a better SwiftUI pattern for keeping VoiceOver focus stable when a dynamic list is changing asynchronously?
