We use a SwiftUI ForEach (using an "id" property on some elements of an array) to render a form with various text fields.
Initially the accessibility sort priority of all these text fields starts as the default 0.00. However when the user submits the form, if there are any validation errors on their entries, we increase the sort priority to 1.00 for the fields with errors, with the goal that the VoiceOver focus would jump to the highest-priority element after the view refreshes.
However, it flat out doesn't work: after changing the accessibility sort priority, nothing actually changes for the user of the app—accessibility still goes in the exact same order as if the sort priority did not exist, and there seems to be no way in SwiftUI to programmatically force the accessibility focus to jump to a particular field that needs attention, or cause a particular field to become the first responder, etc.
A major goal of our project is to see how much we can do in SwiftUI without resorting to using any UIKit APIs (other than UIHostingController), so please bear that in mind when suggesting a solution, thanks!
Initially the accessibility sort priority of all these text fields starts as the default 0.00. However when the user submits the form, if there are any validation errors on their entries, we increase the sort priority to 1.00 for the fields with errors, with the goal that the VoiceOver focus would jump to the highest-priority element after the view refreshes.
However, it flat out doesn't work: after changing the accessibility sort priority, nothing actually changes for the user of the app—accessibility still goes in the exact same order as if the sort priority did not exist, and there seems to be no way in SwiftUI to programmatically force the accessibility focus to jump to a particular field that needs attention, or cause a particular field to become the first responder, etc.
A major goal of our project is to see how much we can do in SwiftUI without resorting to using any UIKit APIs (other than UIHostingController), so please bear that in mind when suggesting a solution, thanks!