Skip to content

Commit 9b0880d

Browse files
committed
fix: update decimal input handling to improve value parsing and user experience
1 parent 08b3690 commit 9b0880d

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

adminforth/spa/src/components/ColumnValueInput.vue

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,12 @@
9191
/>
9292
<Input
9393
v-else-if="(type || column.type) === 'decimal'"
94-
ref="input"
95-
type="text"
96-
inputmode="decimal"
94+
type="number"
95+
step="any"
9796
class="w-40"
98-
:modelValue="cleanDecimalValue(value)"
99-
placeholder="0.0"
100-
:fullWidth="true"
101-
:prefix="column.inputPrefix"
102-
:suffix="column.inputSuffix"
103-
@update:modelValue="(val: string) => $emit('update:modelValue', val.replace(',', '.').replace(/[^\d.]/g, ''))"
104-
@blur="$emit('update:modelValue', cleanDecimalValue(value))"
97+
:modelValue="value ? parseFloat(value) : ''"
98+
@update:modelValue="(val: any) => $emit('update:modelValue', val)"
99+
@blur="$emit('update:modelValue', value ? parseFloat(value).toString() : '')"
105100
/>
106101
<Input
107102
v-else-if="(type || column.type) === 'float'"
@@ -210,8 +205,6 @@
210205
const loadMoreOptions = inject('loadMoreOptions', (() => {}) as any);
211206
212207
const input = ref<HTMLInputElement | null>(null);
213-
const cleanDecimalValue = (v: any) => v?.toString().replace(/(\.[0-9]*[1-9])0+$|\.0+$/, '$1') || '';
214-
215208
const getBooleanOptions = (column: any) => {
216209
const options: Array<{ label: string; value: boolean | null }> = [
217210
{ label: t('Yes'), value: true },

0 commit comments

Comments
 (0)