SwiftUI LazyVGrid - How to fix broken VoiceOver order?

112 views Asked by At

SwiftUI's LazyVGrid seems to read its section titles and items in the wrong order when using VoiceOver. It will read all section titles first and then proceed to the items of the first section:

Actual Behaviour Expected Behaviour
Actual Behaviour Expected Behaviour

Am I doing something wrong? What can I do to change the order (apart from filing a bug with Apple)?

struct ContentView: View {
    let columns = [GridItem(.adaptive(minimum: 80))]
    let collections = (1...3).map { "Collection \($0)" }
    let items = (1...10).map { "Item \($0)" }
    
    var body: some View {
        LazyVGrid(columns: columns, spacing: 16) {
            ForEach(collections) { collection in
                Section(header: Text(collection).font(.title)) {
                    ForEach(items) { item in
                        Text(item)
                            .id(collection+item)
                    }
                }
            }
        }
    }
}

extension String: Identifiable {
    public var id: String {
        return self
    } 
}

0

There are 0 answers