From 182b0b63d1dd8053ab89207f2ee870df624a4cb4 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 10 Jan 2026 21:23:44 +0100 Subject: [PATCH] fix(frontend): preserve numeric type in FormField v-model When modelValue is a number, emit the value as a number instead of coercing to string. This prevents subtle type bugs when using FormField with numeric v-model bindings. --- frontend/src/components/input/FormField.vue | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/input/FormField.vue b/frontend/src/components/input/FormField.vue index 9094ef751..6099cdc2b 100644 --- a/frontend/src/components/input/FormField.vue +++ b/frontend/src/components/input/FormField.vue @@ -11,10 +11,20 @@ interface Props { } const props = defineProps() -defineEmits<{ - 'update:modelValue': [value: string] +const emit = defineEmits<{ + 'update:modelValue': [value: string | number] }>() +function handleInput(event: Event) { + const value = (event.target as HTMLInputElement).value + // Preserve numeric type if modelValue was a number + if (typeof props.modelValue === 'number') { + emit('update:modelValue', value === '' ? '' : Number(value)) + } else { + emit('update:modelValue', value) + } +} + defineOptions({ inheritAttrs: false, }) @@ -83,7 +93,7 @@ defineExpose({ v-bind="{ ...$attrs, ...inputBindings }" :class="inputClasses" :disabled="disabled || undefined" - @input="$emit('update:modelValue', ($event.target as HTMLInputElement).value)" + @input="handleInput" >