You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the Feature Request
A way to imperatively focus the code input at the active input position, rather than relying on just shouldAutoFocus.
Right now, to focus the input, one has to set shouldAutoFocus to true, as that internally focuses the first input. To focus again, one must reset shouldAutoFocus to false and then set it to true. There are many use cases where imperative calling of the focus() function might be required and this is a useful feature to have.
A separate problem is that this hack will only focus the input with index 0, not the activeInput.
Describe Preferred Solution
We could use useImperativeHandle and pass a ref to the otp component, where we impement something like this:
A way to imperatively focus the code input at the active input position, rather than relying on just
shouldAutoFocus
.Right now, to focus the input, one has to set
shouldAutoFocus
to true, as that internally focuses the first input. To focus again, one must resetshouldAutoFocus
tofalse
and then set it totrue
. There are many use cases where imperative calling of thefocus()
function might be required and this is a useful feature to have.A separate problem is that this hack will only focus the input with index 0, not the
activeInput
.We could use
useImperativeHandle
and pass a ref to the otp component, where we impement something like this:If you consider this a viable solution I can open a PR with an implementation.
The text was updated successfully, but these errors were encountered: