Problems combining a .popover and a conditional accessibilityRepresentation

Hello friends/colleagues, I want to create a ViewModifier that accepts a conditional accessibilityIdentifier accepting an optional string input

struct AccessibilityModifier: ViewModifier {

    let identifier: String?

    func body(content: Content) -> some View {
        if let identifier = identifier {
            content
                .accessibilityRepresentation {
                    content
                        .accessibilityIdentifier(identifier)
                }
        } else {
            content
        }
    }
}

it mostly works as expected, but .popover appears to be broken. For example, in the following code, the popover will work. But if I uncomment the .modifier line, the popover does not get presented

struct ContentView: View {

    @State var isPresented: Bool = false

    var body: some View {
        VStack {
            Button("Show Popover") {
                isPresented = true
            }
        }
        .popover(isPresented: $isPresented) {
            Text("A Popover")
        }
//        .modifier(AccessibilityModifier(identifier: "a11y Modifier"))
    }
}

The popover also works when I use:

        .modifier(AccessibilityModifier(identifier: nil))

Any suggestions on how I can support both popovers and my conditional accessibilityIdentifier?

thanks, in advance,

Mike

Problems combining a .popover and a conditional accessibilityRepresentation
 
 
Q