Skip to content

Commit

Permalink
fix: disable paste function on readonly mode
Browse files Browse the repository at this point in the history
  • Loading branch information
navedqb committed May 15, 2024
1 parent 4154d61 commit b6ce44e
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 b6ce44e

Please sign in to comment.