@@ -120,24 +120,25 @@ const ReactInputVerificationCode = ({
120120 index : number
121121 ) => {
122122 const eventValue = event . target . value ;
123- console . log (
124- 'RIVC: onInputChange:eventValue' ,
123+ console . log ( '-------' ) ;
124+ console . log ( 'RIVC:onInputChange' , {
125+ event,
125126 eventValue,
126- eventValue . length
127- ) ;
127+ focusedIndex,
128+ index,
129+ } ) ;
128130
129131 /**
130132 * otp code
131133 */
132134 if ( eventValue . length > 1 ) {
133- console . log ( 'RIVC: isOtp' ) ;
134- console . log ( 'RIVC: isOtp:focusedIndex' , focusedIndex , index ) ;
135-
135+ console . log ( 'RIVC: isOtp' , true ) ;
136136 console . log ( 'RIVC: fillValues(eventValue)' , fillValues ( eventValue ) ) ;
137+
137138 setValues ( fillValues ( eventValue ) ) ;
138139
139140 const isCompleted = eventValue . length === length ;
140- console . log ( 'RIVC isCompleted' , isCompleted ) ;
141+ console . log ( 'RIVC: isCompleted' , isCompleted ) ;
141142
142143 if ( isCompleted ) {
143144 onCompleted ( eventValue ) ;
@@ -148,6 +149,8 @@ const ReactInputVerificationCode = ({
148149 return ;
149150 }
150151
152+ console . log ( 'RIVC: isOtp' , false ) ;
153+
151154 /**
152155 * ensure we only display 1 character in the input
153156 * by clearing the already setted value
@@ -163,7 +166,7 @@ const ReactInputVerificationCode = ({
163166 return ;
164167 }
165168
166- console . log ( 'RIVC: onInputChange:value ' , value ) ;
169+ console . log ( 'RIVC' , { value } ) ;
167170
168171 setValue ( value , index ) ;
169172
@@ -246,16 +249,16 @@ const ReactInputVerificationCode = ({
246249 < div className = 'ReactInputVerificationCode-container' >
247250 { inputsRefs . map ( ( ref , i ) => (
248251 < input
249- { ... ( focusedIndex === i && { autoComplete : 'one-time-code' } ) }
252+ autoComplete = { focusedIndex === i ? 'one-time-code' : 'off' }
250253 className = 'ReactInputVerificationCode-item'
254+ inputMode = { type === 'number' ? 'numeric' : 'text' }
251255 key = { i }
252256 onChange = { ( event ) => onInputChange ( event , i ) }
253257 onFocus = { ( ) => onInputFocus ( i ) }
254258 onKeyDown = { ( event ) => onInputKeyDown ( event , i ) }
255259 onPaste = { ( event ) => onInputPaste ( event , i ) }
256260 placeholder = { placeholder }
257261 ref = { ref }
258- type = { type === 'number' ? 'tel' : 'text' }
259262 value = { values [ i ] }
260263 { ...inputProps }
261264 />
0 commit comments