Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance autoFocus behavior to depend on defaultValue in OTPTextView.TextInput #66

Open
Karamhaj1995 opened this issue Oct 14, 2024 · 0 comments

Comments

@Karamhaj1995
Copy link

I use this input for phone numbers, where the prefix is always 05. As a result, I want the autoFocus to be applied to the third field (index 2) after the prefix.

Currently, the autoFocus property is always applied to the first element - i === 0, which leads to a poor user experience when the defaultValue includes a constant prefix like 05.

To improve this, I suggest considering the length of the defaultValue property when the autoFocus property is true to determine where it should be applied. Instead of using

autoFocus={autoFocus && i === 0}

It would be better to use:

autoFocus={autoFocus && i === defaultValue.length}

This way, the focus will automatically move to the third field (index 2) after the pre-filled prefix, providing a smoother user experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant