-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Labels
P1: High PriorityIssues that would result in incorrectly accessing whether or not a view is accessible.Issues that would result in incorrectly accessing whether or not a view is accessible.Switch Control parityMismatch between output of framework and actual Switch Control behaviorMismatch between output of framework and actual Switch Control behaviorVoiceOver parityMismatch between output of framework and actual VoiceOver behaviorMismatch between output of framework and actual VoiceOver behaviorbugSomething isn't working as expectedSomething isn't working as expected
Description
I've found that when using a NavigationStack
in a SwiftUI view accessibility snapshot puts the contents of the navigation bar below the contents of the view that is contained in the NavigationStack
. That is a lot of words that may or may not be helpful so I'll share some snapshots:
NavigationView | NavigationStack |
---|---|
![]() |
![]() |
Here is the code I used to generate those snapshots:
import AccessibilitySnapshot
import SnapshotTesting
import SwiftUI
import XCTest
class NavigationExampleSnapshotTests: XCTestCase {
func testNavigationView() {
let view = NavigationView {
Text("Text inside a NavigationView")
.navigationTitle("Navigation View")
.toolbar {
ToolbarItem {
Button {
// no-op
} label: {
Text("Add")
}
}
}
}
let hostingController = UIHostingController(rootView: view)
hostingController.view.frame = UIScreen.main.bounds
assertSnapshot(
of: hostingController,
as: .accessibilityImage(drawHierarchyInKeyWindow: true)
)
}
func testNavigationStack() {
let view = NavigationStack {
Text("Text inside a NavigationStack")
.navigationTitle("Navigation Stack")
.toolbar {
ToolbarItem {
Button {
// no-op
} label: {
Text("Add")
}
}
}
}
let hostingController = UIHostingController(rootView: view)
hostingController.view.frame = UIScreen.main.bounds
assertSnapshot(
of: hostingController,
as: .accessibilityImage(drawHierarchyInKeyWindow: true)
)
}
}
I've noticed this issue when running Xcode 15 in an iOS 17 simulator. I have not tested previous simulators but I think the issue is related to NavigationStack
and not to the simulator.
Metadata
Metadata
Assignees
Labels
P1: High PriorityIssues that would result in incorrectly accessing whether or not a view is accessible.Issues that would result in incorrectly accessing whether or not a view is accessible.Switch Control parityMismatch between output of framework and actual Switch Control behaviorMismatch between output of framework and actual Switch Control behaviorVoiceOver parityMismatch between output of framework and actual VoiceOver behaviorMismatch between output of framework and actual VoiceOver behaviorbugSomething isn't working as expectedSomething isn't working as expected