@@ -18,10 +18,12 @@ public struct AccessibilityContainer: Element {
18
18
/// An optional `accessibilityIdentifier` to give the container. Defaults to `nil`.
19
19
public var identifier : String ?
20
20
public var wrapped : Element
21
+ public var accessibilityElements : [ Any ] ?
21
22
22
23
/// Creates a new `AccessibilityContainer` wrapping the provided element.
23
- public init ( identifier: String ? = nil , wrapping element: Element ) {
24
+ public init ( identifier: String ? = nil , accessibilityElements : [ Any ] ? = nil , wrapping element: Element ) {
24
25
self . identifier = identifier
26
+ self . accessibilityElements = accessibilityElements
25
27
wrapped = element
26
28
}
27
29
@@ -36,6 +38,7 @@ public struct AccessibilityContainer: Element {
36
38
public func backingViewDescription( with context: ViewDescriptionContext ) -> ViewDescription ? {
37
39
AccessibilityContainerView . describe { config in
38
40
config [ \. accessibilityIdentifier] = identifier
41
+ config [ \. explicitAccessibilityElements] = self . accessibilityElements
39
42
}
40
43
}
41
44
}
@@ -44,15 +47,17 @@ extension Element {
44
47
45
48
/// Acts as an accessibility container for any subviews
46
49
/// where `isAccessibilityElement == true`.
47
- public func accessibilityContainer( identifier: String ? = nil ) -> Element {
48
- AccessibilityContainer ( identifier: identifier, wrapping: self )
50
+ public func accessibilityContainer( identifier: String ? = nil , accessibilityElements : [ Any ] ? = nil ) -> Element {
51
+ AccessibilityContainer ( identifier: identifier, accessibilityElements : accessibilityElements , wrapping: self )
49
52
}
50
53
}
51
54
52
55
extension AccessibilityContainer {
53
56
private final class AccessibilityContainerView : UIView {
57
+ var explicitAccessibilityElements : [ Any ] ?
58
+
54
59
override var accessibilityElements : [ Any ] ? {
55
- get { recursiveAccessibleSubviews ( ) }
60
+ get { explicitAccessibilityElements ?? recursiveAccessibleSubviews ( ) }
56
61
set { fatalError ( " This property is not settable " ) }
57
62
}
58
63
}
0 commit comments