【发布时间】:2018-10-08 09:30:41
【问题描述】:
我有一个文本输入:
{this.state.showInput
&& (<input
type="number"
min="0"
max="5"
onKeyPress={this.onPressKey}
onChange={this.onChangeHandler}
onBlur={e => this.revertValue(e)}
defaultValue={this.props.initialMark}
ref={this.inputRef}
/>)
}
默认情况下showInput 为假。然后点击一个按钮:
this.setState({ showInput: true }, () => {
if (this.inputRef.current)
this.inputRef.current.focus();
});
使用 onBlur 我将 showInput 的值恢复为 false:
revertValue(e) {
e.target.value = this.props.initialMark;
this.setState({ showInput: false });
}
问题是为什么在触发 onFocus 后我看到模糊被触发,所以我的输入没有出现?如何避免这种行为?
这仅与 Firefox 有关。
【问题讨论】:
-
我也得到了这个......这是一个例子jsfiddle.net/zj04butg/6
标签: javascript reactjs firefox