File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " reactjs-otp-input" ,
3- "version" : " 1.0.1 " ,
3+ "version" : " 1.0.2 " ,
44 "description" : " A fully customizable, one-time password input component for the web built with React" ,
55 "main" : " lib/index.js" ,
66 "scripts" : {
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ class SingleOtpInput extends PureComponent {
101101 hasErrored && errorStyle
102102 ) }
103103 type = { this . getType ( ) }
104- maxLength = "1"
104+ // maxLength='1'
105105 ref = { this . input }
106106 disabled = { isDisabled }
107107 value = { value ? value : '' }
@@ -220,9 +220,15 @@ class OtpInput extends Component {
220220 } ) ;
221221 } ;
222222
223- handleOnChange = ( e ) => {
223+ handleOnChange = ( idx ) => ( e ) => {
224224 const { value } = e . target ;
225225
226+ // Fix Fill value
227+ if ( idx === 0 && value . length === this . props . numInputs ) {
228+ this . handleOtpChange ( value . split ( '' ) ) ;
229+ return ;
230+ }
231+
226232 if ( this . isInputValueValid ( value ) ) {
227233 this . changeCodeAtFocus ( value ) ;
228234 }
@@ -298,7 +304,7 @@ class OtpInput extends Component {
298304 index = { i }
299305 focus = { activeInput === i }
300306 value = { otp && otp [ i ] }
301- onChange = { this . handleOnChange }
307+ onChange = { this . handleOnChange ( i ) }
302308 onKeyDown = { this . handleOnKeyDown }
303309 onInput = { this . handleOnInput }
304310 onPaste = { this . handleOnPaste }
You can’t perform that action at this time.
0 commit comments