There are several ways we are supposed to be able to control a11y (accessibility) focus in FKA (Full Keyboard Access) mode.
We should be able to set up an @AccessibilityFocusState variable that contains an enum for the different views that we want to receive a11y focus. That works from VO (VoiceOver) but not from FKA mode. See this sample project on Github:
Similarly, we are supposed to be able to use accessibilitySortPriority
to control the order that views are selected when a user using FKA tabs between views. That also works from VO but not from FKA mode. In the sample code below, the `.accessibilitySortPriority() ViewModifiers cause VO to change to a non-standard order when you swipe between views, but it has no effect in FKA mode.
Is there a way to either set the a11y focus or change the order in which the views are selected that actually works in SwiftUI when the user is in FKA mode?
Code that should cause FKA to tab between text fields in a custom order:
struct ContentView: View {
@State private var val1: String = "val 1"
@State private var val2: String = "val 2"
@State private var val3: String = "val 3"
@State private var val4: String = "val 4"
var body: some View {
VStack {
TextField("Value 1", text: $val1)
.accessibilitySortPriority(3)
VStack {
TextField("Value 2", text: $val2)
.accessibilitySortPriority(1)
}
HStack {
TextField("Value 3", text: $val3)
.accessibilitySortPriority(2)
TextField("Value 4", text: $val4)
.accessibilitySortPriority(4)
}
}
.padding()
}
}```