From ce1a9877f6192ede46d565dc771c6e5f938564fd Mon Sep 17 00:00:00 2001 From: walt Date: Fri, 11 Feb 2022 18:18:31 +0900 Subject: [PATCH] fix: prevent InputNumber from press literal keys Fixes #2631 and Keeps requirement from #2344 --- components/lib/inputnumber/InputNumber.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/lib/inputnumber/InputNumber.js b/components/lib/inputnumber/InputNumber.js index 8d218ed062..256d7a98e1 100644 --- a/components/lib/inputnumber/InputNumber.js +++ b/components/lib/inputnumber/InputNumber.js @@ -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(); } }