Skip to content

Commit

Permalink
Merge pull request #16085 from BGBRWR/issue-16084
Browse files Browse the repository at this point in the history
fix(keyfilter): regex test with the correct value onKeyPress
  • Loading branch information
cetincakiroglu authored Jul 25, 2024
2 parents 525b383 + b00a21b commit 9de677e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/app/components/keyfilter/keyfilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,9 @@ export class KeyFilter implements Validator {
}

let valueCheck = this.el.nativeElement.value || '';

let val = valueCheck + cc;
const selectionStart = (<HTMLInputElement>e.currentTarget).selectionStart || 0;
const selectionEnd = (<HTMLInputElement>e.currentTarget).selectionEnd || 0;
let val = valueCheck.substring(0, selectionStart) + cc + valueCheck.substring(selectionEnd);

ok = (<RegExp>this.regex).test(val);

Expand Down

0 comments on commit 9de677e

Please sign in to comment.