-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TextInput] Dynamic changing of secureTextEntry breaks font and doesn't change cursor position #5859
Comments
Hey aksonov, thanks for reporting this issue! React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
|
(edit by @hramos: link to Snack with repro: https://snack.expo.io/Bk1CsdRE7) You are right. that's definitely a bug. But checkout my solution below. Add a space character to text and delete it again. the cursor will be at the right position. /*jslint node: true */
'use strict';
import React, {
Component,
StyleSheet,
View,
TextInput,
Switch
} from 'react-native';
class Example extends Component {
constructor( props) {
super(props);
this.state = {
isSecureTextEntry : true,
password : '123456'
};
}
render() {
return (
<View style={{
flex : 1,
backgroundColor : '#F5FCFF'
}}>
<Switch
onValueChange={(value) =>{
this.setState({isSecureTextEntry: value});
this.setState({ password : this.state.password + ' ' });
this.setState({ password : this.state.password.substring(0, this.state.password.length - 1)});
}}
style={{marginLeft: 20, marginTop : 50}}
value={this.state.isSecureTextEntry}
/>
<TextInput
style={{ height: 40, borderColor: 'gray',
borderWidth: 1, marginLeft : 20, marginTop : 50}}
onChangeText={(text) => this.setState({password : text})}
secureTextEntry = {this.state.isSecureTextEntry}
value={this.state.password}
/>
</View>
);
}
}
module.exports = Example; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is going to be fixed by #6564 I believe. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Appears to still exist in 0.30, as reported in this SO question. I also previously reported this with dupe #5710. @charpeni could we consider reopening this? |
This comment has been minimized.
This comment has been minimized.
I've written a thread about this. |
Still exists in 0.33.0. I'm also experiencing an additional issue when updating secureTextEntry dynamically. When changing from false to true, the text passed into the onChangeText function is empty when additional text is typed. //edit: Just built the same screen in native code (Swift on iOS.) Turns out my "additional issue" is just the native iOS behaviour. The font issue ALSO appears in native iOS code. What solved it for me was to blur the input field before switching the secureTextEntry prop and then focus it again. In this case the input field keeps its custom font. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is still happening on RN 0.50.4 -- any updates? |
I've reopened this issue. If you are thinking of contributing this fix, please let me know - I am more than happy to help you and give as many ideas as possible. |
This comment has been minimized.
This comment has been minimized.
This is for those who were facing the following issue. |
You can find a full repro of this here: https://snack.expo.io/Bk1CsdRE7 Repro steps:
|
@sghosh968 I am still experiencing this issue in RN v0.56.0. Could you post an example where this is working as expected? |
Sorry for posting without checking first looking at the gif it seemed the issue was fixed, should have checked first. @andrejcesen, I recently upgraded an app from v0.52 to 0.56 and found the issue still persists. |
PR #18587 fixes this, I just need a hand from a maintainer/someone who knows more of Objective-C to reiterate based on @janicduplessis requests. |
|
0.55.4 still get issue |
I have the same issue on 0.57.5 |
The issue is still not resolved. You can check it here : https://snack.expo.io/Bk1CsdRE7 |
Summary: This is a fix for #5859, based on the feedback in #18587. Instead of using `didSetProps` it uses a setter. I will also note that setting to `nil` no longer works (crashes) so setting it to a blank string then back to the original works fine. [iOS] [Fixed] - Toggling secureTextEntry correctly places cursor. Pull Request resolved: #23524 Differential Revision: D14143028 Pulled By: cpojer fbshipit-source-id: 5f3203d56b1329eb7359465f8ab50eb4f4fa5507
i think this is because you're not using the setState callback, should be:
Can't get it to reproduce on android s8 |
Summary: This is a fix for #5859, based on the feedback in #18587. Instead of using `didSetProps` it uses a setter. I will also note that setting to `nil` no longer works (crashes) so setting it to a blank string then back to the original works fine. [iOS] [Fixed] - Toggling secureTextEntry correctly places cursor. Pull Request resolved: #23524 Differential Revision: D14143028 Pulled By: cpojer fbshipit-source-id: 5f3203d56b1329eb7359465f8ab50eb4f4fa5507
Fixed: #23524. |
I need to have show/hide password option for TextInput.
Dynamic changing of secureTextEntry breaks font and doesn't change cursor position. It probably happens because font for "*" is fixed and it is not changed back when securyTextEntry is false.
The text was updated successfully, but these errors were encountered: