In SwiftUI, the content and cursor are intermittently outside the bounds of the TextEditor.
struct ContentView: View {
@State private var text = ""
var body: some View {
VStack {
TextEditor(text: $text)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.border(Color.gray, width: 1)
}
.padding()
}
}
I enter multiline text into TextEditor.
The content and cursor are intermittently outside the bounds of the TextEditor at the bottom.
Screen recording:
The problem also appears on my iPad.
I guess it may be related to the input method.
Is it possible to solve this problem?
It seems that TextEditor
doesn't correctly manage the size of the scrolling content, which I believe is a framework bug. I’d suggest that you file a feedback report for the SwiftUI folks to investigate – If you do so, please share your report ID here.
When hitting a SwiftUI issue that doesn't have a good solution, I typically consider using the UIKit or AppKit counterpart. Here, UITextView
+ UIViewRepresentable
may be the rescue.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.