Skip to content

Commit 754c686

Browse files
author
sadik-malik
committed
fix: readValueAsDate return value if not string
1 parent b4241a5 commit 754c686

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/rhf-mui/src/utils.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ export function getTimezone<TDate extends PickerValidDate>(
2424
export function readValueAsDate<TDate extends PickerValidDate>(
2525
adapter: ReturnType<typeof useLocalizationContext>,
2626
value: string | null | TDate
27-
): TDate | null {
28-
return value && typeof value === 'string' ? adapter.utils.date(value) as TDate: null
27+
): TDate | null | string {
28+
if(typeof value === 'string'){
29+
if(value === ''){
30+
return null
31+
}
32+
return adapter.utils.date(value) as TDate
33+
}
34+
return value
2935
}

0 commit comments

Comments
 (0)