diff --git a/packages/ui/src/components/va-date-input/VaDateInput.stories.ts b/packages/ui/src/components/va-date-input/VaDateInput.stories.ts
index 6b9985ee14..d5fe468b58 100644
--- a/packages/ui/src/components/va-date-input/VaDateInput.stories.ts
+++ b/packages/ui/src/components/va-date-input/VaDateInput.stories.ts
@@ -221,3 +221,16 @@ export const AsyncDate = () => ({
`,
})
+
+export const NullValue = () => ({
+ components: { VaDateInput },
+ data () {
+ return {
+ value: null,
+ }
+ },
+ template: `
+ [[value]]: {{ value === null ? 'null' : value }}
+
+ `,
+})
diff --git a/packages/ui/src/components/va-date-input/VaDateInput.vue b/packages/ui/src/components/va-date-input/VaDateInput.vue
index 060c32647f..b26a0a3132 100644
--- a/packages/ui/src/components/va-date-input/VaDateInput.vue
+++ b/packages/ui/src/components/va-date-input/VaDateInput.vue
@@ -126,7 +126,7 @@ const props = defineProps({
...useValidationProps as ValidationProps,
...useComponentPresetProp,
- clearValue: { type: Date as PropType, default: undefined },
+ clearValue: { type: undefined as unknown as PropType, default: undefined },
modelValue: { type: [Date, Array, Object, String, Number] as PropType },
resetOnClose: { type: Boolean, default: true },
@@ -239,7 +239,7 @@ const modelValueToString = (value: DateInputModelValue): string => {
return ''
}
- throw new Error('VaDatePicker: Invalid model value. Value should be Date, Date[] or { start: Date, end: Date | null }, got ' + typeof value)
+ return ''
}
const {
@@ -263,10 +263,10 @@ const valueText = computed(() => {
const onInputTextChanged = ({ target }: Event) => {
if (props.disabled) { return }
- const parsedValue = parseDateInputValue((target as HTMLInputElement).value)
+ const inputValue = (target as HTMLInputElement).value
if (isValid.value) {
- valueComputed.value = parsedValue
+ valueComputed.value = inputValue === '' ? props.clearValue : parseDateInputValue(inputValue)
}
}