gluestack-ui icon indicating copy to clipboard operation
gluestack-ui copied to clipboard

Password input value resets when toggling visibility on iOS

Open yanoyuki opened this issue 1 year ago • 4 comments

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

  1. The initial type of the password input field is "password".
  2. Enter a password.
  3. Next, click the eye icon to change the type to "text".
  4. Continue entering the password.
  5. Click the eye icon again to change the type back to "password".
  6. 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 avatar Jul 14 '24 02:07 yanoyuki

@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

makkarMeenu avatar Jul 14 '24 05:07 makkarMeenu

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 avatar Jul 14 '24 06:07 yanoyuki

@yanoyuki You may be want to check this out https://github.com/facebook/react-native/issues/35668

makkarMeenu avatar Jul 14 '24 06:07 makkarMeenu

@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.

yanoyuki avatar Jul 15 '24 09:07 yanoyuki

This is from react-native side https://github.com/facebook/react-native/issues/12939

Sanchitv3 avatar Apr 09 '25 10:04 Sanchitv3