Skip to content

Issue with Navigation and accessibility #376

Open
@honkmaster

Description

@honkmaster

Description

I have an app with the basic structure of a NavigationView which contains a ScrollView. If the user taps an element in the ScrollView, the app navigates to a detail view. The ScrollView is modified using Introspect (v. 1.1.0). Additionally, the ScrollView has set some accessibility attributes to be used in XCUITests. Here is an example of the code.

ScrollView(.horizontal, showsIndicators: false) {
    content
      .accessibilityIdentifier("Bar")
}
.introspect(.scrollView, on: .iOS(.v16, .v17)) { scrollView in
    pagedScrollViewDelegator.width = geometry.size.width + spacing

    scrollView.decelerationRate = .fast
    scrollView.clipsToBounds = false
    scrollView.alwaysBounceVertical = false
    scrollView.delegate = pagedScrollViewDelegator
}
.accessibilityElement(children: .contain)
.accessibilityIdentifier("Foo")

Now there is a problem in the XCUI tests. When the app starts for the first time, all accessibility identifier are set correctly. XCUITests can navigate. But when the tests comes back to the start page, all accessibility identifier inside the modified ScrollView are gone from the hierarchy. If we remove the modification of the ScrollView with Introspect, the test works, the identifier remain even after navigation.

Checklist

Expected behavior

Accessibility accessibility should remain

Actual behavior

Accessibility accessibility are gone after navigation

Steps to reproduce

See above.

Version information

1.1.0

Destination operating system

16.4

Xcode version information

Xcode 15.0

Swift Compiler version information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions