iOS 16 TextEditor long text jumping (SwiftUI)

Text jumping (I don't know how else to name that weird behavior) to the top(?) every time user enters a new character. I can reproduce the issue only on iPad OS 16. It affects the user who attempts to write long (several paragraphs) text in the TextEditor.

It is reproduced with the following code (just past five or more paragraphs of Lorem Ipsum and start typing).

class EditorViewModel: ObservableObject {
    @Published var text: String = ""
}

struct EditorView: View {
    @ObservedObject var viewModel: EditorViewModel

    var body: some View {
        VStack {
            TextEditor(text: $viewModel.text)
                .frame(height: 80)
                .padding()
                .background(Color.red)
            Spacer()
        }
    }
}

struct ContentView: View {
    var body: some View {
        EditorView(
            viewModel: EditorViewModel()
        )
    }
}

There is the link to StackOverflow with the issue's gif.

I'm running into the same behavior.

Is the problem solved? I'm experiencing the same problem.

TextEditor not working well with large chunk of text and new lines.

Just remove @Published and use any mechanism that not cause SwiftUI to recompute view tree changes while you typing.

The text doesn't have to be long. I've just noticed when you've got more than 40 lines the content gets into spasm.

iOS 16 TextEditor long text jumping (SwiftUI)
 
 
Q