I have multiple text editors inside a scroll view and I want the text editors to not be scrollable. Currently, if the cursor is located inside a text editor, then the latter is being scrolled and not the scroll view. How can I prevent this from happening?
struct ContentView: View {
var body: some View {
ScrollView(.vertical) {
ForEach(1 ... 30, id: \.self) { _ in
ElementView(text: "")
}
}
.padding()
}
}
struct ElementView: View {
@State var text: String
var body: some View {
ZStack(alignment: .leading) {
TextEditor(text: $text)
Text(text)
.opacity(0)
.fixedSize(horizontal: false, vertical: true)
}.border(Color.red)
}
}