Skip to content

Commit

Permalink
Merge pull request #7 from anchaljain123/fix/clear-field
Browse files Browse the repository at this point in the history
fixing clearing issue
  • Loading branch information
naveenvignesh5 authored Oct 28, 2019
2 parents 935099f + 2ac2f71 commit 55bf002
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class OTPTextView extends PureComponent {

onKeyPress = (e, i) => {
const { otpText = [] } = this.state;
if (e.nativeEvent.key === 'Backspace' && i !== 0 && otpText[i] === '') {
//Since otpText[i] is undefined, The clear operation is not functional
if (e.nativeEvent.key === 'Backspace' && i !== 0 && !otpText[i]) {
this.inputs[i-1].focus();
}
}
Expand Down

0 comments on commit 55bf002

Please sign in to comment.