Skip to content

Commit f01c9a9

Browse files
committed
fix: simplify decimal input handling by removing unnecessary editing state
1 parent 58d2d09 commit f01c9a9

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

adminforth/spa/src/components/ColumnValueInput.vue

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,9 @@
9595
type="text"
9696
inputmode="decimal"
9797
class="w-40"
98-
placeholder="0.0"
99-
:fullWidth="true"
100-
:prefix="column.inputPrefix"
101-
:suffix="column.inputSuffix"
102-
:modelValue="isEditing ? value : cleanDecimalValue(value)"
103-
@focus="() => {
104-
isEditing = true;
105-
$emit('update:modelValue', cleanDecimalValue(value));
106-
}"
98+
:modelValue="cleanDecimalValue(value)"
10799
@update:modelValue="(val: string) => $emit('update:modelValue', val.replace(',', '.').replace(/[^\d.]/g, ''))"
108-
@blur="() => {
109-
isEditing = false;
110-
$emit('update:modelValue', cleanDecimalValue(value));
111-
}"
100+
@blur="$emit('update:modelValue', cleanDecimalValue(value))"
112101
/>
113102
<Input
114103
v-else-if="(type || column.type) === 'float'"
@@ -217,8 +206,7 @@
217206
const loadMoreOptions = inject('loadMoreOptions', (() => {}) as any);
218207
219208
const input = ref<HTMLInputElement | null>(null);
220-
const isEditing = ref(false);
221-
const cleanDecimalValue = (v: any) => v?.toString().replace(/(\.[0-9]*[1-9])0+$|\.0+$/, '$1') || '';
209+
const cleanDecimalValue = (v: any) => v?.toString().replace(/(\.[0-9]*[1-9])0+$|\.0+$/, '$1') || '';
222210
223211
const getBooleanOptions = (column: any) => {
224212
const options: Array<{ label: string; value: boolean | null }> = [

0 commit comments

Comments
 (0)