Skip to content

Commit

Permalink
fix: prevent InputNumber from press literal keys
Browse files Browse the repository at this point in the history
Fixes primefaces#2631
and Keeps requirement from primefaces#2344
  • Loading branch information
walt1992 committed Feb 11, 2022
1 parent 3dc8ced commit ce1a987
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/lib/inputnumber/InputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,14 +534,15 @@ export class InputNumber extends Component {
}

let code = event.which || event.keyCode;

if (code !== 13) event.preventDefault();

let char = String.fromCharCode(code);
const isDecimalSign = this.isDecimalSign(char);
const isMinusSign = this.isMinusSign(char);

if ((48 <= code && code <= 57) || isMinusSign || isDecimalSign) {
this.insert(event, char, { isDecimalSign, isMinusSign });

event.preventDefault();
}
}

Expand Down

0 comments on commit ce1a987

Please sign in to comment.