Why are the child elements inheriting the parent accessibility identifier?

235 Views Asked by At

I have this view (and accessibility identifier):

private var carStack: some View {
    CarSwiftUIView(viewModel: viewModel.carViewModel)
        .accessibilityIdentifier("car")
        .accessibilityElement(children: .ignore)
}

If I use .ignore or .contain, the child elements within the CarSwiftUIView have the same named accessibility identifiers (car) as what's specified above.

Using .combine, I think, gives every child element the same identifier by default.

How can I make it so there's a parent accessibility identifier of car, and then within that view, I can name the child elements with different identifiers?

Thank you.

1

There are 1 best solutions below

0
On BEST ANSWER

They were inheriting the parent's accessibilityIdentifier because they're not strictly "children". They are elements which form part of the parent's view.