-
Notifications
You must be signed in to change notification settings - Fork 49.3k
Closed
Description
Hello,
The autoFocus attribute is not triggered on a render therefor it is impossible to change the focus with that attribute if there are multiple fields.
Currently the only way to change the focus is to give the input a ref and change it on componentDidUpdate()
componentDidUpdate() {
if ( this.props.isAutoFocus === true ) {
this.refs['input' + this.props.line ].focus();
}
}
tempRender = (<li className="content editable" ref={ 'CalculationItem' }>
<input
ref={ 'input' + this.props.line }
autoFocus={ this.props.isAutoFocus }
/>
</li>);
The autoFocus attribute will only work on the initial render.
pgarciacamou, michalpuskel, charliwize and rocktimsaikia
Metadata
Metadata
Assignees
Labels
No labels