I am using two number inputs on my page.
I have implemented some logic to move the focus to the second input once the first has been filled out.
The focus is moved to the second input field but immediately after, the focus is moved back to the first input field. How do I prevent it from moving the focus back?
Here is a simplified version of how it is implemented:
```
class MyClass extends React.Component {
firstRef
secondRef
componentDidUpdate(prevProps) {
if(!prevProps.done && this.props.done) {
secondRef.focus();
}
render () {
return (
You can try putting secondRef.focus(); inside a timeout with 0ms.
The above behaviour is happening because of
https://github.com/s-yadav/react-number-format/blob/master/src/number_format.js#L251
which is required as patch for mobile browser.
@s-yadav Thanks it worked beautifully!
Most helpful comment
You can try putting
secondRef.focus();inside a timeout with 0ms.The above behaviour is happening because of
https://github.com/s-yadav/react-number-format/blob/master/src/number_format.js#L251
which is required as patch for mobile browser.