I have a Group of a SecureField and a TextField in order to simulate the ability to toggle the password from hidden to showing. The TextField works as intended even if I go to another field or anywhere on the view so it makes me think that my problem isn't with my states (I'm using a password Published var in a viewModel I take from the Environment).
With the Secure field though (so when the password is not visible) if I have already typed and then lose focus and come back to it and type again it resets. It's also the same if I remove the TextField and keep only the SecureField in my Group. I wonder if it's the default functionality of the SecureField or I have to add a modifier I can't find.
To give an even better picture, I have a didSet on my variable and it shows the following see console log(printing twice on each activity I think because of the TextField). The 4*aaaa is 2 for the first time changed to aaaa and the next 2 for when I click in the above TextField. Then when I reclick to the SecureField nothing happens and when I type a again the last four lines are printed.
Thanks in advance for any help you might provide. :)
Group{
if (!loginViewModel.showPassword) {
SecureField("password".localizableString(appViewModel.language),
text: $loginViewModel.password)
}else {
TextField("password".localizableString(appViewModel.language),
text: $loginViewModel.password)
.autocapitalization(.none)
.padding(.vertical, -0.75)
}
}
.disableAutocorrection(true)
.padding(.vertical, -2)
.modifier(PlaceholderStyle(showPlaceHolder: loginViewModel.password.isEmpty, placeholder: "password".localizableString(appViewModel.language)))
.foregroundColor(Color("TextDefault"))
.keyboardType(.emailAddress)