From b6ce44eb1467040ba9e073240f19d6122be81ea5 Mon Sep 17 00:00:00 2001 From: navedqb Date: Wed, 15 May 2024 10:26:30 +0530 Subject: [PATCH] fix: disable paste function on readonly mode --- src/app/components/inputotp/inputotp.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/app/components/inputotp/inputotp.ts b/src/app/components/inputotp/inputotp.ts index b2061e3f174..8b52ecf6c72 100644 --- a/src/app/components/inputotp/inputotp.ts +++ b/src/app/components/inputotp/inputotp.ts @@ -321,18 +321,20 @@ export class InputOtp implements AfterContentInit { } onPaste(event) { - let paste = event.clipboardData.getData('text'); + if (!this.disabled && !this.readonly) { + let paste = event.clipboardData.getData('text'); - if (paste.length) { - let pastedCode = paste.substring(0, this.length + 1); + if (paste.length) { + let pastedCode = paste.substring(0, this.length + 1); - if (!this.integerOnly || !isNaN(pastedCode)) { - this.tokens = pastedCode.split(''); - this.updateModel(event); + if (!this.integerOnly || !isNaN(pastedCode)) { + this.tokens = pastedCode.split(''); + this.updateModel(event); + } } - } - event.preventDefault(); + event.preventDefault(); + } } getRange(n: number): number[] {