From 4f36a786811308275ee7162eb9cede2ba77d3d38 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 16 Jul 2024 12:13:16 +0200 Subject: [PATCH] feat: curso in start when is 00:00 --- src/components/common/VnInputTime.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/common/VnInputTime.vue b/src/components/common/VnInputTime.vue index 31ac7c04f..adb6ef68c 100644 --- a/src/components/common/VnInputTime.vue +++ b/src/components/common/VnInputTime.vue @@ -72,15 +72,18 @@ watch( watch( () => formattedTime.value, async (val) => { + let position = 3; const input = inputRef.value?.getNativeElement(); if (!val || !input) return; - const [hh, mm] = val.split(':'); - if (parseInt(hh) >= 10 || mm != '00') return; + let [hh, mm] = val.split(':'); + hh = parseInt(hh); + if (hh >= 10 || mm != '00') return; await nextTick(); await nextTick(); - input.setSelectionRange(3, 3); + if (!hh) position = 0; + input.setSelectionRange(position, position); }, { immediate: true } ); @@ -99,6 +102,7 @@ watch( style="min-width: 100px" :rules="$attrs.required ? [requiredFieldRule] : null" @click="isPopupOpen = false" + @focus="inputRef.getNativeElement().setSelectionRange(0, 0)" >