From 1d9c036f31a9923f63406a77f7c280195ab34310 Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Wed, 24 Apr 2024 11:10:15 +0300 Subject: [PATCH] Fixed #5545 - InputNumber Not Working android --- components/lib/inputnumber/InputNumber.vue | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/components/lib/inputnumber/InputNumber.vue b/components/lib/inputnumber/InputNumber.vue index 2a63df9347..ef86b5ff2c 100755 --- a/components/lib/inputnumber/InputNumber.vue +++ b/components/lib/inputnumber/InputNumber.vue @@ -10,6 +10,7 @@ :aria-valuemin="min" :aria-valuemax="max" :aria-valuenow="modelValue" + :inputmode="mode === 'decimal' && !minFractionDigits ? 'numeric' : 'decimal'" :disabled="disabled" :readonly="readonly" :placeholder="placeholder" @@ -18,6 +19,7 @@ :aria-invalid="invalid || undefined" @input="onUserInput" @keydown="onInputKeyDown" + @keypress="onInputKeyPress" @paste="onPaste" @click="onInputClick" @focus="onInputFocus" @@ -525,21 +527,24 @@ export default { break; default: - if (this.readonly) { - return; - } - - event.preventDefault(); + break; + } + }, + onInputKeyPress(event) { + if (this.readonly) { + return; + } - let char = event.key; - const isDecimalSign = this.isDecimalSign(char); - const isMinusSign = this.isMinusSign(char); + let char = event.key; + let isDecimalSign = this.isDecimalSign(char); + const isMinusSign = this.isMinusSign(char); - if ((Number(char) >= 0 && Number(char) <= 9) || isMinusSign || isDecimalSign) { - this.insert(event, char, { isDecimalSign, isMinusSign }); - } + if (event.code !== 'Enter') { + event.preventDefault(); + } - break; + if ((Number(char) >= 0 && Number(char) <= 9) || isMinusSign || isDecimalSign) { + this.insert(event, char, { isDecimalSign, isMinusSign }); } }, onPaste(event) {