Skip to content

Commit b32e130

Browse files
authored
Merge pull request #44 from n3m/bugfix/onComplete-falsely-triggered
Fixed onCompleted trigger when placeholder is one character/digit
2 parents 7663e9d + 5185bd5 commit b32e130

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"test:watch": "react-scripts test --env=jsdom",
3838
"release": "npm run test && npm run prepare && dotenv release-it",
3939
"lint": "eslint . --ext .js,.ts,.tsx",
40-
"format": "prettier --write {src,playground}",
40+
"format": "prettier --write {src,playground}/**/*.{ts,tsx}",
4141
"format:check": "prettier --check {src,playground}/**/*.{ts,tsx}"
4242
},
4343
"peerDependencies": {
@@ -93,4 +93,4 @@
9393
"input",
9494
"autocompletion"
9595
]
96-
}
96+
}

src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ const ReactInputVerificationCode = ({
156156
const stringValue = value.join('');
157157
const isCompleted = stringValue.length === length;
158158

159-
if (isCompleted) onCompleted(stringValue);
159+
if (isCompleted && stringValue !== emptyValue.join(''))
160+
onCompleted(stringValue);
160161
onChange(stringValue);
161162
}, [value, length]);
162163

0 commit comments

Comments
 (0)