Merge pull request #4 from qburst/#5336-fix-inputotp-length-not-working

Fix #5336: InputOtp Length not working
pull/5383/head
Amal Mathew 2024-03-07 10:35:03 +05:30 committed by GitHub
commit 6cbf7828f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -129,6 +129,13 @@ export default {
this.$emit('blur', event); this.$emit('blur', event);
}, },
onKeyDown(event) { onKeyDown(event) {
const newValue = this.tokens.join('');
let limitReached = false;
if (newValue.length >= this.length) {
limitReached = true;
}
const keyCode = event.keyCode; const keyCode = event.keyCode;
switch (keyCode) { switch (keyCode) {
@ -167,7 +174,9 @@ export default {
if (this.integerOnly && !(event.keyCode >= 48 && event.keyCode <= 57)) { if (this.integerOnly && !(event.keyCode >= 48 && event.keyCode <= 57)) {
event.preventDefault(); event.preventDefault();
} }
if (limitReached && event.keyCode != 46) {
event.preventDefault();
}
break; break;
} }
}, },