SwiftUI: .textSelection(.enabled) not working in List on iOS 18

In iOS 18, textSelection(_:) not working in List. So, I can't copy text. Works on iOS 17 and earlier. Is this a bug and is there any solution?

// Not Work: iOS 18
struct ContentView: View {
    var body: some View {
        List {
            Text("Hello World")
                .textSelection(.enabled)
        }
    }
}

// Work: iOS 18 and earlier
struct ContentView: View {
    var body: some View {
        Text("Hello World")
            .textSelection(.enabled)
    }
}
Answered by donchan922 in 811461022

In iOS 18.1, textSelection(_:) works in List! https://stackoverflow.com/a/79135453/11073133

Ran into this as well. Filed FB15178192 to track with a simple repro case similar to the one above.

temporary workaround to use https://github.com/jayrhynas/EditMenu

Accepted Answer

In iOS 18.1, textSelection(_:) works in List! https://stackoverflow.com/a/79135453/11073133

In iOS 18.1, textSelection(_:) works in List! https://stackoverflow.com/a/79135453/11073133

Thank you so much! I was working on enabling text copying in my app and spent hours wondering why .textSelection(.enabled) wasn’t working. However, thanks to your post, I realized that the issue was due to testing on the iOS 18.0 simulator. I tested it with the iOS 18.1 simulator, and it was solved beautifully. Without your post, I would have spent several more hours struggling. I sincerely appreciate it from the bottom of my heart.

SwiftUI: .textSelection(.enabled) not working in List on iOS 18
 
 
Q