Skip to content

Commit

Permalink
Merge pull request #24 from navedqb/fix-disable-paste-functionality-i…
Browse files Browse the repository at this point in the history
…n-readonly-mode

fix: disable paste function on readonly mode
  • Loading branch information
navedqb authored May 15, 2024
2 parents 4154d61 + b6ce44e commit 7d83b18
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/app/components/inputotp/inputotp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down

0 comments on commit 7d83b18

Please sign in to comment.