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
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.
The text was updated successfully, but these errors were encountered:
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 thedefaultValue
includes a constant prefix like05
.To improve this, I suggest considering the length of the
defaultValue
property when theautoFocus
property istrue
to determine where it should be applied. Instead of usingIt would be better to use:
This way, the focus will automatically move to the third field (index 2) after the pre-filled prefix, providing a smoother user experience.
The text was updated successfully, but these errors were encountered: