fix crash on attempt to change password

This commit is contained in:
or-else
2022-06-29 18:39:00 -07:00
parent 2a00791a1b
commit e209ef2483
6 changed files with 21 additions and 9 deletions
+9 -3
View File
@@ -5,6 +5,8 @@ export default class VisiblePassword extends React.PureComponent {
constructor(props) {
super(props);
this.inputRef = React.createRef();
this.state = {
value: this.props.value,
visible: false
@@ -16,6 +18,10 @@ export default class VisiblePassword extends React.PureComponent {
this.handleEditingFinished = this.handleEditingFinished.bind(this);
}
componentDidMount() {
this.inputRef.current.focus();
}
handeTextChange(e) {
this.setState({value: e.target.value});
if (this.props.onChange) {
@@ -58,8 +64,7 @@ export default class VisiblePassword extends React.PureComponent {
render() {
return (
<div tabIndex="-1" className="group-focus"
onBlur={this.handleEditingFinished}>
<div tabIndex="-1" className="group-focus" onBlur={this.handleEditingFinished}>
<input className="with-visibility"
type={this.state.visible ? "text" : "password"}
value={this.state.value}
@@ -68,7 +73,8 @@ export default class VisiblePassword extends React.PureComponent {
autoFocus={this.props.autoFocus ? 'autoFocus' : ''}
autoComplete={this.props.autoComplete}
onChange={this.handeTextChange}
onKeyDown={this.handleKeyDown} />
onKeyDown={this.handleKeyDown}
ref={this.inputRef} />
<span onClick={this.handleVisibility}>
<i className="material-icons clickable light-gray">
{this.state.visible ? 'visibility' : 'visibility_off'}