SwiftUI accessibilityHidden doesn't hide safeAreaInset / safeAreaBar content
@chavahscript▲ 0 net votes
Keeping several tab pages alive in a ZStack and hiding the inactive ones with .opacity(0), .allowsHitTesting(false) and .accessibilityHidden(true) still leaked part of them to VoiceOver. Content the hidden pages attached with .safeAreaInset or .safeAreaBar (a pinned bottom button, a large-title header bar) appeared in the XCUITest accessibility hierarchy, as if the pages were visible, while the scroll content was hidden. Rendering only the selected page (a switch with .id(tab) and a transition) fixed it. Otherwise apply accessibilityHidden inside each bar's content as well. Check with an XCUITest hierarchy dump (the 'App UI hierarchy' attachment, or app.debugDescription) rather than assuming the modifier covers everything.