TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Accessibility with Forms

Forums > SwiftUI

Today I was playing around with Accessibility labels in SwiftUI. I noticed one strange behavior when trying to apply accessibility to my Form. It looks that if i use Section with a header it's always blocking all elements afterwards from reading it's values in Accessibility Inspectior.

I did try the code below inspecting with Accessibility Inspector. When i have the first Section without header it will work well until i reach the second Section. There it will only read out the "Hello World" and ignore all elements afterwards.

Did anyone notice this already and has an idea how to solve it or is it a bug in SwiftUI?

Form {
                    Section {
                        Button("Push Me") {
                            print("Button Pushed")
                        }
                            TextField("Name", text: $textfield)
                            .accessibility(label: Text("Textfield"))
                    }

                    Section(header: Text("Hello World")) {
                        Button("Push Me") {
                            print("Button Pushed")
                        }
                            TextField("Name", text: $textfield)
                            .accessibility(label: Text("Textfield"))
                    }
                }

3      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.