Skip to content

Commit

Permalink
fix(DateField): error thrown when value is null and changing locale (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia authored Dec 6, 2024
1 parent 908ea8c commit f9b77f2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/radix-vue/src/DateField/DateFieldRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type DateValue, isEqualDay } from '@internationalized/date'
import type { Ref } from 'vue'
import type { PrimitiveProps } from '@/Primitive'
import { type Formatter, createContext, useDateFormatter, useDirection, useKbd } from '@/shared'
import { type Formatter, createContext, isNullish, useDateFormatter, useDirection, useKbd } from '@/shared'
import {
type Granularity,
type HourCycle,
Expand Down Expand Up @@ -192,12 +192,12 @@ watch(locale, (value) => {
})
watch(modelValue, (_modelValue) => {
if (_modelValue !== undefined && (!isEqualDay(placeholder.value, _modelValue) || placeholder.value.compare(_modelValue) !== 0))
if (!isNullish(_modelValue) && (!isEqualDay(placeholder.value, _modelValue) || placeholder.value.compare(_modelValue) !== 0))
placeholder.value = _modelValue.copy()
})
watch([modelValue, locale], ([_modelValue]) => {
if (_modelValue !== undefined) {
if (!isNullish(_modelValue)) {
segmentValues.value = { ...syncSegmentValues({ value: _modelValue, formatter }) }
}
else if (Object.values(segmentValues.value).every(value => value === null) || _modelValue === undefined) {
Expand Down

0 comments on commit f9b77f2

Please sign in to comment.