You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cursor position resets on toggling value of secure property of TextField on Android #3181
Now, when we change isPasswordVisible value programmatically, it works great on iOS. But on android it always resets the cursor position to the first character.
I tried to find the root cause of the issue and found that whenever setInputType is called, android will reset the cursor position to the first character.
I checked the code of text-field.android.js and the issue is we are calling setInputType but we are not setting the cursor to its original position. This results in cursor resets to first character. So just getting the cursor position before calling setInputType and setting that cursor position after calling setInputType will solve this issue as shown below.
text-field.android.js
function onSecurePropertyChanged(data) {
var textField = data.object;
...
var cursor = textField.android.getSelectionStart();
...
textField.android.setInputType(newInputType);
textField.android.setSelection(cursor);
}
Edit
I also noted that currently when secure is set to false, the input type is being set to TYPE_TEXT_VARIATION_NORMAL. This opens a different soft keyboard than that is visible when secure is true. So it will be great if we can have some provision so that when password is visible (secure is false), the inputType is set to TYPE_TEXT_VARIATION_VISIBLE_PASSWORD instead of TYPE_TEXT_VARIATION_NORMAL. This will keep the soft keyboard same irrespective of whether password is visible or not.
Which platform(s) does your issue occur on?
Android
Please provide the following version numbers that your issue occurs with:
CLI: 2.4.0
Cross-platform modules: 2.4.0
Runtime(s): 2.4.1
Let me know if you want me to create a PR for this.
Thanks for reporting this one - we are welcoming all PRs from the community that can improve and solve existing issues. If you want to contribute all you have to do is to sign the CLA and follow the contributors guide.
Activity
NickIliev commentedon Nov 28, 2016
Hey @shripalsoni04
Thanks for reporting this one - we are welcoming all PRs from the community that can improve and solve existing issues. If you want to contribute all you have to do is to sign the CLA and follow the contributors guide.
Fix for issue NativeScript#3181 to maintain cursor position on toggle…
Fix for issue #3181 to maintain cursor position on toggle of secure f…
GurgenHOVH commentedon Nov 30, 2017
I have this issue with NativeScript 3.3.1.
AmitGurbani commentedon Jul 16, 2019
Same issue with version 5.4.2