devfolioco / react-otp-input

:heavy_check_mark: OTP Input Component for React
http://devfolioco.github.io/react-otp-input
MIT License
654 stars 424 forks source link

Title: Restrict focus to first empty input field #398

Open nasim67reja opened 1 year ago

nasim67reja commented 1 year ago

Hello,

I have been using the react-otp-input package and I have found an issue with the way the focus is handled. Currently, if I click on the third or fourth input field and enter a value, the value is entered in the first input field and the focus moves to the next input field which ones i have clicked for example four if i clicked one three. This behavior is not intuitive and can be confusing for users.

I would like to request a feature where the focus is restricted to the first empty input field. This means that if a user clicks on any input field, the focus should automatically move to the first empty input field. This will ensure that users can only enter values sequentially and will prevent any confusion.

Thank you for considering this feature request. I look forward to hearing your thoughts on this.

Best regards, Nasim

RemyMachado commented 9 months ago

I second this, but I would ask for some more. I think it would make sense to allow for users to navigate to any empty field. What doesn't make sense is the bug which fills the wrong input.

It would be great if we had an option to choose between the two: