diff --git a/src/VueDatePicker/VueDatePicker.vue b/src/VueDatePicker/VueDatePicker.vue index ebe55186..18998902 100644 --- a/src/VueDatePicker/VueDatePicker.vue +++ b/src/VueDatePicker/VueDatePicker.vue @@ -239,7 +239,7 @@ emitModelValue, formatInputValue, checkBeforeEmit, - } = useExternalInternalMapper(emit, props, isInputFocused); + } = useExternalInternalMapper(emit, props, { isInputFocused, isTextInputDate }); const wrapperClass = computed( (): DynamicClass => ({ @@ -469,7 +469,7 @@ selectDate(); emit('text-submit'); } else if (props.autoApply) { - autoApplyValue(); + autoApplyValue(true); } nextTick().then(() => { isTextInputDate.value = false; diff --git a/src/VueDatePicker/composables/external-internal-mapper.ts b/src/VueDatePicker/composables/external-internal-mapper.ts index 815ff991..e6563d6a 100644 --- a/src/VueDatePicker/composables/external-internal-mapper.ts +++ b/src/VueDatePicker/composables/external-internal-mapper.ts @@ -24,7 +24,11 @@ import { modelTypePredefined } from '@/constants'; /** * Handles values from external to internal and vise versa */ -export const useExternalInternalMapper = (emit: VueEmit, props: AllPropsType, isInputFocused: Ref) => { +export const useExternalInternalMapper = ( + emit: VueEmit, + props: AllPropsType, + { isInputFocused, isTextInputDate }: { isInputFocused: Ref; isTextInputDate: Ref }, +) => { const internalModelValue = ref(); const { defaultedTextInput, defaultedRange, defaultedTz, defaultedMultiDates, getDefaultPattern } = @@ -267,6 +271,9 @@ export const useExternalInternalMapper = (emit: VueEmit, props: AllPropsType, is * Also does the validation of the provided value, if invalid it will use null as a default or an empty value */ const parseExternalModelValue = (value: ModelValue): void => { + // Prevent text input from being overridden by external value while typing + if (isTextInputDate.value) return; + const mappedDate = mapExternalToInternal(value); if (isValidDate(convertType(mappedDate))) {