Detect link taps in the AttributedString version of TextEditor?

iOS 26 added an AttributedString version of TextEditor. It can display links but I have no idea how to detect when a user taps them. This is possible when using a Text element and the openURL environment modifier, but this doesn't seem to work with TextEditor?

e.g.

struct ContentView: View {
    var text: AttributedString {
        var attributedString = AttributedString("Link")
        attributedString.link = URL(string: "https://www.apple.com")
        return attributedString
    }

    var body: some View {
        TextEditor(text: .constant(text))
            .environment(\.openURL, OpenURLAction { url in
                // This is not called.
                print(url)
                return .handled
            })
    }
}

Any ideas?

Currently, the TextEditor doesn’t intercept links when clicked using the OpenURLAction handler. Please file an enhancement request using Feedback Assistant. Once you’ve submitted the request, kindly share the Facebook number here. If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?.

You could use UITextView text item methods in UITextViewDelegate to provide a custom action when someone interacts with a link.

Detect link taps in the AttributedString version of TextEditor?
 
 
Q