Skip to content

onBlur event triggers when trying to set focus on input[type"number"] on conditional rendering in Firefox #11062

@mdekalka

Description

@mdekalka

Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When trying to render input[type="number"] with active focus on click

state = {
    isShown: true,
    value: 0
}
componentDidUpdate() {
    this.input && this.input.focus();
}
//...
render() {
    return (
      <td className="editable">
        {!this.state.isShown ? (
          <input
            type="number"
            ref={(input) => { this.input = input }}
            value={this.state.value}
            onChange={e =>
              this.setState({
                value: e.target.value
              })}
            onBlur={() => {this.setState({ isShown: true })}}
          />
        ) : (
            <span onClick={() => {this.setState({ isShown: false })}}>Click me</span>
          )}
      </td>
    )
}

onBlur event triggers in Firefox, before even focus is set.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem:
Click on name column to render input[type="number"] with active focus(works in Chrome, IE11, Edge, does not in Firefox). Please see live example:
https://codepen.io/piupiupiu/pen/KXXQdb?editors=0010

What is the expected behavior?
After clicking on name column input should appears with active focus

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React v15.4.2
Firefox v56.0 Win10

I'm not sure if this React issue actually, because I noticed that if you will change input type to text if will works perfectly in Firefox(so the problem related only to input[type="number"])

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions