When I press space on the keyboard in TextEditor, “parent button click” is printed in the application console, but the space is not put in the TextEditor. There are no such problems with other characters. How to get space in TextEditor in that case?
import SwiftUI
struct ContentView: View {
@State private var showPopoverComment = false
var body: some View {
Button(action: {
print("parent button click")
}) {
VStack {
Button("child button", action: {showPopoverComment = true})
.popover(isPresented: $showPopoverComment) {
EditCommentView()
.frame(width: 100, height: 100)
}
// other views ...
}
}.buttonStyle(.plain)
}
}
struct EditCommentView: View {
@State var comment: String = ""
var body: some View {
TextEditor(text: $comment)
}
}