Skip to content

Commit

Permalink
Update focus to input after last pasted value or last input #70
Browse files Browse the repository at this point in the history
  • Loading branch information
acusti committed Oct 14, 2021
1 parent 50293d5 commit 631bae4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/ReactCodeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ class ReactCodeInput extends Component {
}
});

const newTarget = this.textInput[targetIndex < input.length
? targetIndex + 1
: targetIndex];
const newTargetIndex = Math.min(value.length + targetIndex, this.props.fields - 1);
const newTarget = this.textInput[newTargetIndex];

if (newTarget) {
newTarget.focus();
Expand Down

0 comments on commit 631bae4

Please sign in to comment.