Password input value resets when toggling visibility on iOS
Description
When toggling the visibility of a password input field using an eye icon, the input value is reset. This issue occurs when switching between type="password" and type="text".
CodeSandbox/Snack link
https://snack.expo.dev/@y.yano/gluestack-ui?platform=ios
Steps to reproduce
Steps to Reproduce
- The initial type of the password input field is "password".
- Enter a password.
- Next, click the eye icon to change the type to "text".
- Continue entering the password.
- Click the eye icon again to change the type back to "password".
- Enter one more character, and all previous input is reset, requiring you to start typing from the beginning.
https://github.com/user-attachments/assets/bcb257b6-7254-4aa5-849b-803164945414
gluestack-ui Version
"@gluestack-ui/config": "^1.1.19",
"@gluestack-ui/themed": "^1.1.38",
"@gluestack-style/react": "^1.0.57"
Platform
- [ ] Expo
- [ ] React Native CLI
- [ ] Next
- [ ] Web
- [ ] Android
- [X] iOS
Other Platform
No response
Additional Information
This issue occurs only on iOS and does not happen on Android or Web.
The sample code used in Snack is almost identical to the example code provided on the following page: https://gluestack.io/ui/docs/components/forms/input
@yanoyuki This is default react-native TextInput behaviour.
You can check here in this expo snack. https://snack.expo.dev/bhK1tUd4IXwXu-U0Pof_N?platform=ios
Thank you for your response.
So, this is not an issue with Gluestack but rather a problem with React Native and iOS.
Is there any workaround to address this iOS behavior?
@yanoyuki You may be want to check this out https://github.com/facebook/react-native/issues/35668
@makkarMeenu
As mentioned stack overflow,
textField.clearsOnBeginEditing = NO;
I understand that this resolves the issue, but it seems there is no way to directly avoid this from React Native without touching the native code.
This is from react-native side https://github.com/facebook/react-native/issues/12939