-
Notifications
You must be signed in to change notification settings - Fork 140
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
autoFocus is not running perfectly (most of the time) #72
Comments
I'm having same issue. |
For me it is working on iOS (Simulator), but not on Android: const PincodeInput = ({
value,
setValue,
inputRef,
onFulfill
}) => (
<SmoothPincodeInput
password
mask="*"
ref={inputRef}
containerStyle={styles.wrapper}
cellStyle={styles.cell}
cellStyleFocused={styles.cellFocused}
textStyle={styles.cellText}
value={value}
onTextChange={setValue}
onFulfill={onFulfill}
restrictToNumbers={true}
animationFocused={null}
autoFocus={true}
/>
) |
Same here, autoFocus works on iOS but not on Android. My workaround was to delay rendering SmoothPincodeInput a few ms after mounting my component. |
Thanks @MatiasArriola, I noticed that I had to delay rendering for a second in order to see the keyboard. This was my solution: const PincodeInput = ({
value,
setValue,
inputRef,
onFulfill
}) => {
useEffect(() => {
setTimeout(() => {
// Fix auto focus for Android
inputRef.current.focus()
}, 1000)
}, [inputRef])
return (
<SmoothPincodeInput
password
mask="*"
ref={inputRef}
containerStyle={styles.wrapper}
cellStyle={styles.cell}
cellStyleFocused={styles.cellFocused}
textStyle={styles.cellText}
value={value}
onTextChange={setValue}
onFulfill={onFulfill}
restrictToNumbers={true}
animationFocused={null}
autoFocus={true}
/>
)
} |
Remove the autoFocus attribute if not you will have some issues.
|
if you have modal in prev screen, don't close the modal just move to your otp screen, and this my PIN screen, for your reference
|
setting autofocus true does'nt make it smooth when component did mount, also tried ref method but still does'nt working
The text was updated successfully, but these errors were encountered: