UIViewRepresentable disappears when contextMenu is activated on iOS 14

Originator:henrycooper93
Number:rdar://FB9073856 Date Originated:04/09/2021
Status:Open Resolved:
Product:SwiftUI (iOS) Product Version:iOS 14
Classification:BUG Reproducible:Yes
 
Observed:

When using a UIViewRepresentable with an attached contextMenu modifier, the view will not show in the highlighted bar of the activated context menu on iOS 14.

Expected:

UIViewRepresentable should propagate into highlighted bar as per iOS 13.

--------------------------------------------------------------------------

struct ContentView: View {
    var body: some View {
        Spacer()
        MyTextView(string: "I work on iOS 13 but not iOS 14")
            .contextMenu {
                Button("Menu Item 1") {}
            }
        Spacer()
    }
}

struct MyTextView: View {
    var string: String
    var body: some View {
        NativeTextContentView(string: string).frame(width: 100, height: 100)
    }
}

struct NativeTextContentView: UIViewRepresentable {
    
    var string: String
    
    func makeUIView(context: Context) -> UITextView {
        let textView = UITextView()
        return textView
    }
    
    func updateUIView(_ textView: UITextView, context: Context) {
        textView.text = string
    }
}

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!