diff --git a/src/lib/index.jsx b/src/lib/index.jsx index 267e2288..29b6380a 100644 --- a/src/lib/index.jsx +++ b/src/lib/index.jsx @@ -184,7 +184,7 @@ class OtpInput extends Component { handleOnPaste = (e: Object) => { e.preventDefault(); const { numInputs } = this.props; - const { activeInput } = this.state; + var { activeInput } = this.state; const otp = this.getOtpValue(); // Get pastedData in an array of max size (num of inputs - current position) @@ -197,9 +197,13 @@ class OtpInput extends Component { for (let pos = 0; pos < numInputs; ++pos) { if (pos >= activeInput && pastedData.length > 0) { otp[pos] = pastedData.shift(); + activeInput++; } } + this.setState({ activeInput }); + this.focusInput(activeInput); + this.handleOtpChange(otp); };