Skip to content

AutoFocus attribute is not triggered on render #5534

@yolcuiskender

Description

@yolcuiskender

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions