Skip to content

Instantly share code, notes, and snippets.

@mattyoung
Last active May 16, 2022 07:15
Show Gist options
  • Save mattyoung/44e7019d435aa00195ebc858304c4dbc to your computer and use it in GitHub Desktop.
Save mattyoung/44e7019d435aa00195ebc858304c4dbc to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
VStack {
// accessiblity works normally
VStack {
Text("NavigationLink accessiblilty is fine when not .combine")
NavigationLink(destination: Text("Destination")) {
Text("I'm a NavigationLink")
}
}
Divider()
// accessibility bug: NavigationLink accessibility is lost
// when VStack container has more than one views in it and has .accessibilityElement(children: .combine)
VStack {
#warning("When there more views than just NavigationLink, only Text's are read out, this one is read out")
Text("A Label")
#warning("No accessibility for any NavigationLink")
NavigationLink(destination: Text("Destination")) {
Text("If you can hear this, then no bug")
}
// and this one is also read out
Text("Another Label")
}
.accessibilityElement(children: .combine)
#warning(".combine then NavigationLink accessibility is lost")
Divider()
VStack {
NavigationLink(destination: Text("Destination")) {
Text("Works here if this is the only view")
}
}
.accessibilityElement(children: .combine)
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment