TextField's text color is wrong

STR:

  1. Enter email into the text field – test+ap11@gmail.com
  2. Change the foregroundColor of the text field by tapping the "Change color" button

ER: The color of the complete label is changed. The whole label is red.

AR: The label color is changed partly. Some of characters are red, some of them are black.

Environment: Only iOS 16 (iOS 15 is ok)

struct ContentView: View {
  @State var text = ""
  @State var isRed = false
   
  var body: some View {
    VStack {
      TextField("enter text here", text: $text)
        .foregroundColor(isRed ? .red : .black)
      Button {
        isRed = !isRed
      } label: {
        Text("Change color")
      }
    }
  }
}

What are STR, ER and AR ?

From the small amount of testing I have just done, it seems to be related to the autocorrection behaviour of the text field. The misspelt words (dotted underlined in red, sometimes) seem not to be affected by the colour change, but the rest of the text does.

This is definitely a bug and you should file a feedback report about it, regardless.

In the meantime, apply this modifier to the TextField and it should be resolved (it is for me):

.autocorrectionDisabled()

Steps To Reproduce, Expected Result, Actual Result?

TextField's text color is wrong
 
 
Q