From 33b9a1ba1f3cb959a0a0194be8cd42f165dfa0ff Mon Sep 17 00:00:00 2001 From: Amal Mathew Date: Thu, 7 Mar 2024 10:33:38 +0530 Subject: [PATCH 1/2] 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; } }, From 211b2520253201f2007f448ff170fbc4fdfbec4d Mon Sep 17 00:00:00 2001 From: Amal Mathew Date: Thu, 7 Mar 2024 10:44:01 +0530 Subject: [PATCH 2/2] Fix #5336: InputOtp Length not working - lint fix --- components/lib/inputotp/InputOtp.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/lib/inputotp/InputOtp.vue b/components/lib/inputotp/InputOtp.vue index 93937075b..e54501b57 100755 --- a/components/lib/inputotp/InputOtp.vue +++ b/components/lib/inputotp/InputOtp.vue @@ -174,9 +174,11 @@ export default { if (this.integerOnly && !(event.keyCode >= 48 && event.keyCode <= 57)) { event.preventDefault(); } + if (limitReached && event.keyCode != 46) { event.preventDefault(); } + break; } },