'TextEditor weird jumping animation

When using TextEditor and enabling animations (e.g. .animation(.default)) the text 'jumps' up and slides back down when entering a \n in the keyboard. I suspect it is because the Text frame gets higher instantly, while the VStack containing the text is expanding slowly due to the animation. Even when increasing the animation speed or using only .animation(.easyOut) the issue remains. Code to reproduce:

init() {
 UITextView.appearance().backgroundColor = .clear // to remove old background color
}

VStack {
 TextEditor(text: $example)
  .background(Color.red
   .clipShape(RoundedRectangle(cornerRadius: 20)))
 }
.animation(.default)

edit: I guess this also comes down to adjusting the height of the textEditor by the content inside



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source