@@ -120,24 +120,25 @@ const ReactInputVerificationCode = ({
120
120
index : number
121
121
) => {
122
122
const eventValue = event . target . value ;
123
- console . log (
124
- 'RIVC: onInputChange:eventValue' ,
123
+ console . log ( '-------' ) ;
124
+ console . log ( 'RIVC:onInputChange' , {
125
+ event,
125
126
eventValue,
126
- eventValue . length
127
- ) ;
127
+ focusedIndex,
128
+ index,
129
+ } ) ;
128
130
129
131
/**
130
132
* otp code
131
133
*/
132
134
if ( eventValue . length > 1 ) {
133
- console . log ( 'RIVC: isOtp' ) ;
134
- console . log ( 'RIVC: isOtp:focusedIndex' , focusedIndex , index ) ;
135
-
135
+ console . log ( 'RIVC: isOtp' , true ) ;
136
136
console . log ( 'RIVC: fillValues(eventValue)' , fillValues ( eventValue ) ) ;
137
+
137
138
setValues ( fillValues ( eventValue ) ) ;
138
139
139
140
const isCompleted = eventValue . length === length ;
140
- console . log ( 'RIVC isCompleted' , isCompleted ) ;
141
+ console . log ( 'RIVC: isCompleted' , isCompleted ) ;
141
142
142
143
if ( isCompleted ) {
143
144
onCompleted ( eventValue ) ;
@@ -148,6 +149,8 @@ const ReactInputVerificationCode = ({
148
149
return ;
149
150
}
150
151
152
+ console . log ( 'RIVC: isOtp' , false ) ;
153
+
151
154
/**
152
155
* ensure we only display 1 character in the input
153
156
* by clearing the already setted value
@@ -163,7 +166,7 @@ const ReactInputVerificationCode = ({
163
166
return ;
164
167
}
165
168
166
- console . log ( 'RIVC: onInputChange:value ' , value ) ;
169
+ console . log ( 'RIVC' , { value } ) ;
167
170
168
171
setValue ( value , index ) ;
169
172
@@ -246,16 +249,16 @@ const ReactInputVerificationCode = ({
246
249
< div className = 'ReactInputVerificationCode-container' >
247
250
{ inputsRefs . map ( ( ref , i ) => (
248
251
< input
249
- { ... ( focusedIndex === i && { autoComplete : 'one-time-code' } ) }
252
+ autoComplete = { focusedIndex === i ? 'one-time-code' : 'off' }
250
253
className = 'ReactInputVerificationCode-item'
254
+ inputMode = { type === 'number' ? 'numeric' : 'text' }
251
255
key = { i }
252
256
onChange = { ( event ) => onInputChange ( event , i ) }
253
257
onFocus = { ( ) => onInputFocus ( i ) }
254
258
onKeyDown = { ( event ) => onInputKeyDown ( event , i ) }
255
259
onPaste = { ( event ) => onInputPaste ( event , i ) }
256
260
placeholder = { placeholder }
257
261
ref = { ref }
258
- type = { type === 'number' ? 'tel' : 'text' }
259
262
value = { values [ i ] }
260
263
{ ...inputProps }
261
264
/>
0 commit comments