Skip to content

Commit 3fee224

Browse files
blenderskoolapollonian
authored andcommitted
Fixed same input not triggering next focus
1 parent e96b59c commit 3fee224

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib/index.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ class OtpInput extends Component<Props, State> {
223223
}
224224
};
225225

226+
// The content may not have changed, but some input took place hence change the focus
227+
handleInput = (e: Object) => {
228+
this.handleOnChange(e);
229+
this.checkLength(e);
230+
}
231+
226232
checkLength = (e: Object) => {
227233
if (e.target.value.length > 1) {
228234
e.preventDefault();
@@ -255,7 +261,7 @@ class OtpInput extends Component<Props, State> {
255261
value={otp && otp[i]}
256262
onChange={this.handleOnChange}
257263
onKeyDown={this.handleOnKeyDown}
258-
onInput={this.checkLength}
264+
onInput={this.handleInput}
259265
onPaste={this.handleOnPaste}
260266
onFocus={e => {
261267
this.setState({ activeInput: i });

0 commit comments

Comments
 (0)