diff --git a/src/components/common/VnInputTime.vue b/src/components/common/VnInputTime.vue index 9344ff869..e10838672 100644 --- a/src/components/common/VnInputTime.vue +++ b/src/components/common/VnInputTime.vue @@ -2,6 +2,7 @@ import { watch, computed, ref } from 'vue'; import { useI18n } from 'vue-i18n'; import { date } from 'quasar'; +import { nextTick } from 'vue'; const model = defineModel({ type: String }); const props = defineProps({ @@ -43,7 +44,7 @@ const formattedTime = computed({ if (time?.length > 5) time = dateToTime(time); if (!props.timeOnly) { const hours = time.split(':'); - const date = new Date(); + const date = Date.vnNew(); date.setHours(hours[0], hours[1], 0); time = date.toISOString(); } @@ -55,17 +56,24 @@ const formattedTime = computed({ function dateToTime(newDate) { return date.formatDate(new Date(newDate), dateFormat); } - +const timeField = ref(); watch( () => model.value, (val) => (formattedTime.value = val), { immediate: true } ); +const focusField = () => { + nextTick(() => { + const input = timeField.value.$el.querySelector('input'); + input.setSelectionRange(0, 0); + }); +};