diff --git a/front/src/components/ui/Pill.vue b/front/src/components/ui/Pill.vue index 7b7aab35b..6fef3ca68 100644 --- a/front/src/components/ui/Pill.vue +++ b/front/src/components/ui/Pill.vue @@ -3,22 +3,30 @@ import { ref, onMounted } from 'vue' import { type ColorProps, type PastelProps, type VariantProps, type RaisedProps, color } from '~/composables/color' -const input = ref(); +const input = ref(); const emit = defineEmits<{ click: [event: MouseEvent] }>() const handleClick = (event: MouseEvent) => { emit('click', event); if (model.value !== undefined) { - (input.value as HTMLInputElement).focus(); + input.value?.focus(); } } const props = defineProps<{ noUnderline?:true, autofocus? : boolean } & (PastelProps | ColorProps) & VariantProps & RaisedProps>() const model = defineModel() onMounted(() => { - if (props.autofocus) input.value.focus(); + if (props.autofocus) input.value?.focus(); }) + +const sanitize = () => + model.value = model.value?.replace(',', '')?.trim() + +const sanitizeAndBlur = () => + sanitize() && input.value?.blur() + +