Skip to content

Commit

Permalink
fix: update champ input numeric (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
OCTO-GUIC authored Oct 14, 2024
1 parent 51f7017 commit f357328
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/components/custom/Form/InputNumeric.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
<input
class="fr-input"
type="text"
:value="defaultValue"
v-model="internalValue"
:id="id"
:name="id"
inputmode="numeric"
pattern="[0-9]*"
@input="updateValue"
/>
</template>

<script setup lang="ts">
defineProps<{
import { ref, watch } from 'vue';
const props = defineProps<{
id: string;
label: { wording: string; cssModifier?: string };
defaultValue?: string;
Expand All @@ -26,8 +27,9 @@
(e: 'update:modelValue', value: string): void;
}>();
const updateValue = async event => {
const { value } = event.target as HTMLInputElement;
emit('update:modelValue', value);
};
const internalValue = ref(props.defaultValue || '');
watch(internalValue, newValue => {
emit('update:modelValue', newValue);
});
</script>

0 comments on commit f357328

Please sign in to comment.