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
+1 -1
View File
@@ -110,6 +110,7 @@ export default class InPlaceEdit extends React.Component {
attr.type = this.props.type || 'text'; attr.type = this.props.type || 'text';
} }
attr.value = this.state.value; attr.value = this.state.value;
attr.ref = this.selfRef;
attr.onChange = this.handeTextChange; attr.onChange = this.handeTextChange;
attr.onKeyDown = this.handleKeyDown; attr.onKeyDown = this.handleKeyDown;
attr.onBlur = this.handleEditingFinished; attr.onBlur = this.handleEditingFinished;
@@ -118,7 +119,6 @@ export default class InPlaceEdit extends React.Component {
attr.required = this.props.required ? 'required' : ''; attr.required = this.props.required ? 'required' : '';
attr.autoComplete = this.props.autoComplete; attr.autoComplete = this.props.autoComplete;
attr.autoFocus = true; attr.autoFocus = true;
attr.ref = this.selfRef;
return React.createElement(element, attr, null); return React.createElement(element, attr, null);
} }
+9 -3
View File
@@ -5,6 +5,8 @@ export default class VisiblePassword extends React.PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.inputRef = React.createRef();
this.state = { this.state = {
value: this.props.value, value: this.props.value,
visible: false visible: false
@@ -16,6 +18,10 @@ export default class VisiblePassword extends React.PureComponent {
this.handleEditingFinished = this.handleEditingFinished.bind(this); this.handleEditingFinished = this.handleEditingFinished.bind(this);
} }
componentDidMount() {
this.inputRef.current.focus();
}
handeTextChange(e) { handeTextChange(e) {
this.setState({value: e.target.value}); this.setState({value: e.target.value});
if (this.props.onChange) { if (this.props.onChange) {
@@ -58,8 +64,7 @@ export default class VisiblePassword extends React.PureComponent {
render() { render() {
return ( return (
<div tabIndex="-1" className="group-focus" <div tabIndex="-1" className="group-focus" onBlur={this.handleEditingFinished}>
onBlur={this.handleEditingFinished}>
<input className="with-visibility" <input className="with-visibility"
type={this.state.visible ? "text" : "password"} type={this.state.visible ? "text" : "password"}
value={this.state.value} value={this.state.value}
@@ -68,7 +73,8 @@ export default class VisiblePassword extends React.PureComponent {
autoFocus={this.props.autoFocus ? 'autoFocus' : ''} autoFocus={this.props.autoFocus ? 'autoFocus' : ''}
autoComplete={this.props.autoComplete} autoComplete={this.props.autoComplete}
onChange={this.handeTextChange} onChange={this.handeTextChange}
onKeyDown={this.handleKeyDown} /> onKeyDown={this.handleKeyDown}
ref={this.inputRef} />
<span onClick={this.handleVisibility}> <span onClick={this.handleVisibility}>
<i className="material-icons clickable light-gray"> <i className="material-icons clickable light-gray">
{this.state.visible ? 'visibility' : 'visibility_off'} {this.state.visible ? 'visibility' : 'visibility_off'}
+8 -2
View File
@@ -14433,6 +14433,7 @@ class InPlaceEdit extends (react__WEBPACK_IMPORTED_MODULE_0___default().Componen
} }
attr.value = this.state.value; attr.value = this.state.value;
attr.ref = this.selfRef;
attr.onChange = this.handeTextChange; attr.onChange = this.handeTextChange;
attr.onKeyDown = this.handleKeyDown; attr.onKeyDown = this.handleKeyDown;
attr.onBlur = this.handleEditingFinished; attr.onBlur = this.handleEditingFinished;
@@ -14442,7 +14443,6 @@ class InPlaceEdit extends (react__WEBPACK_IMPORTED_MODULE_0___default().Componen
attr.required = this.props.required ? 'required' : ''; attr.required = this.props.required ? 'required' : '';
attr.autoComplete = this.props.autoComplete; attr.autoComplete = this.props.autoComplete;
attr.autoFocus = true; attr.autoFocus = true;
attr.ref = this.selfRef;
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(element, attr, null); return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(element, attr, null);
} }
@@ -17259,6 +17259,7 @@ __webpack_require__.r(__webpack_exports__);
class VisiblePassword extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComponent) { class VisiblePassword extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComponent) {
constructor(props) { constructor(props) {
super(props); super(props);
this.inputRef = react__WEBPACK_IMPORTED_MODULE_0___default().createRef();
this.state = { this.state = {
value: this.props.value, value: this.props.value,
visible: false visible: false
@@ -17269,6 +17270,10 @@ class VisiblePassword extends (react__WEBPACK_IMPORTED_MODULE_0___default().Pure
this.handleEditingFinished = this.handleEditingFinished.bind(this); this.handleEditingFinished = this.handleEditingFinished.bind(this);
} }
componentDidMount() {
this.inputRef.current.focus();
}
handeTextChange(e) { handeTextChange(e) {
this.setState({ this.setState({
value: e.target.value value: e.target.value
@@ -17330,7 +17335,8 @@ class VisiblePassword extends (react__WEBPACK_IMPORTED_MODULE_0___default().Pure
autoFocus: this.props.autoFocus ? 'autoFocus' : '', autoFocus: this.props.autoFocus ? 'autoFocus' : '',
autoComplete: this.props.autoComplete, autoComplete: this.props.autoComplete,
onChange: this.handeTextChange, onChange: this.handeTextChange,
onKeyDown: this.handleKeyDown onKeyDown: this.handleKeyDown,
ref: this.inputRef
}), react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", { }), react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
onClick: this.handleVisibility onClick: this.handleVisibility
}, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("i", { }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("i", {
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long