cashapp / AccessibilitySnapshot

Easy regression testing for iOS accessibility
Apache License 2.0
534 stars 65 forks source link

Incorrect sort order for SwiftUI Form in iOS 16 #129

Open yonaskolb opened 1 year ago

yonaskolb commented 1 year ago

The order of parsed accessibility markers is in the wrong order. See screenshot, where the section headings are parsed as being at the bottom of the view. This is a SwiftUI view with no animations. Is there a workaround for this? The order is important to me as I use the accessibility markers to create a markdown representation of the view.

testExample MainA11y

NickEntin commented 1 year ago

Hi @yonaskolb, thanks for reporting this! Can you provide a code sample that reproduces this issue? Additionally, what iOS version are you testing on?

yonaskolb commented 1 year ago

Thanks for the quick reply @NickEntin. Example project showing the issue attached. I'm using iOS 16.4 in Xcode 14.3 SnapshotExample.zip testExample Form

yonaskolb commented 1 year ago

The example also highlights a different issue with the rendering of forms, which there is an unresolved issue for in SnapshotTesting https://github.com/pointfreeco/swift-snapshot-testing/issues/667 If using drawHierarchyInKeyWindow: true in the example that issue is fixed but the rendering is offset incorrectly. Don't want to confuse the issue, just wanted to mention that too in case you're wondering why the snapshot looks weird.

testExample Form

yonaskolb commented 1 year ago

Any updates on this one?

NickEntin commented 1 year ago

I haven't had a chance to test on Xcode 14.3 yet, but on Xcode 13.3 it seems to be behaving correctly. I'll dig in further this week.

NickEntin commented 1 year ago

Still working on this one. There was definitely a change in iOS 16 that we're not currently handling properly. Looking at sample view you provided, in iOS 15 it's backed by a table view and in iOS 16 it's backed by a collection view.

iOS 15 iOS 16

It looks like with collection views it's using an accessibility container with a single element view (that's not an accessibility element) which then has subviews that are themselves accessibility containers each with a single element. Somewhere in this nesting we don't order things the same as VoiceOver.

yonaskolb commented 2 months ago

Fixed by https://github.com/cashapp/AccessibilitySnapshot/pull/169