From 33b9a1ba1f3cb959a0a0194be8cd42f165dfa0ff Mon Sep 17 00:00:00 2001 From: Amal Mathew Date: Thu, 7 Mar 2024 10:33:38 +0530 Subject: [PATCH] Fix #5336: InputOtp Length not working --- components/lib/inputotp/InputOtp.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/lib/inputotp/InputOtp.vue b/components/lib/inputotp/InputOtp.vue index 7a390d6df..93937075b 100755 --- a/components/lib/inputotp/InputOtp.vue +++ b/components/lib/inputotp/InputOtp.vue @@ -129,6 +129,13 @@ export default { this.$emit('blur', event); }, onKeyDown(event) { + const newValue = this.tokens.join(''); + let limitReached = false; + + if (newValue.length >= this.length) { + limitReached = true; + } + const keyCode = event.keyCode; switch (keyCode) { @@ -167,7 +174,9 @@ export default { if (this.integerOnly && !(event.keyCode >= 48 && event.keyCode <= 57)) { event.preventDefault(); } - + if (limitReached && event.keyCode != 46) { + event.preventDefault(); + } break; } },