Skip to content

Commit

Permalink
Merge pull request #15274 from primefaces/issue-12316
Browse files Browse the repository at this point in the history
Fixed #12316 - KeyFilter | Pasting Valid data into a pKeyFilter field…
  • Loading branch information
cetincakiroglu authored Apr 18, 2024
2 parents c7206ea + 173f40f commit 0695b55
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/app/components/keyfilter/keyfilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,20 @@ export class KeyFilter implements Validator {
onPaste(e: ClipboardEvent) {
const clipboardData = e.clipboardData || (<any>this.document.defaultView).clipboardData.getData('text');
if (clipboardData) {
let pattern = /\{[0-9]+\}/;
const pastedText = clipboardData.getData('text');
for (let char of pastedText.toString()) {
if (!this.regex.test(char)) {
if (pattern.test(this.regex.toString())) {
if (!this.regex.test(pastedText)) {
e.preventDefault();
return;
}
} else {
for (let char of pastedText.toString()) {
if (!this.regex.test(char)) {
e.preventDefault();
return;
}
}
}
}
}
Expand Down

0 comments on commit 0695b55

Please sign in to comment.