@@ -120,28 +120,16 @@ const ReactInputVerificationCode = ({
120120 index : number
121121 ) => {
122122 const eventValue = event . target . value ;
123- /**
124- * ensure we only display 1 character in the input
125- * by clearing the already setted value
126- */
127- const value = eventValue . replace ( values [ index ] , '' ) ;
128-
129- /**
130- * if the value is not valid, don't go any further
131- * and select the content of the input for a better UX
132- */
133- if ( ! validate ( value ) ) {
134- selectInputContent ( index ) ;
135- return ;
136- }
137-
138- console . log ( 'RIVC: onInputChange:eventValue' , eventValue ) ;
139- console . log ( 'RIVC: onInputChange:value' , value ) ;
123+ console . log (
124+ 'RIVC: onInputChange:eventValue' ,
125+ eventValue ,
126+ eventValue . length
127+ ) ;
140128
141129 /**
142130 * otp code
143131 */
144- if ( value . length > 1 ) {
132+ if ( eventValue . length > 1 ) {
145133 console . log ( 'RIVC: isOtp' ) ;
146134
147135 console . log ( 'RIVC: fillValues(eventValue)' , fillValues ( eventValue ) ) ;
@@ -159,6 +147,23 @@ const ReactInputVerificationCode = ({
159147 return ;
160148 }
161149
150+ /**
151+ * ensure we only display 1 character in the input
152+ * by clearing the already setted value
153+ */
154+ const value = eventValue . replace ( values [ index ] , '' ) ;
155+
156+ /**
157+ * if the value is not valid, don't go any further
158+ * and select the content of the input for a better UX
159+ */
160+ if ( ! validate ( value ) ) {
161+ selectInputContent ( index ) ;
162+ return ;
163+ }
164+
165+ console . log ( 'RIVC: onInputChange:value' , value ) ;
166+
162167 setValue ( value , index ) ;
163168
164169 /**
0 commit comments