mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-01 19:06:12 +01:00
Fix client-side error when editing date with keyboard (Closes #43)
This commit is contained in:
@@ -165,9 +165,7 @@ export function ExpenseForm({
|
|||||||
<Input
|
<Input
|
||||||
className="date-base"
|
className="date-base"
|
||||||
type="date"
|
type="date"
|
||||||
value={(field.value ?? new Date())
|
defaultValue={formatDate(field.value)}
|
||||||
.toISOString()
|
|
||||||
.substring(0, 10)}
|
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
return field.onChange(new Date(event.target.value))
|
return field.onChange(new Date(event.target.value))
|
||||||
}}
|
}}
|
||||||
@@ -552,3 +550,8 @@ export function ExpenseForm({
|
|||||||
</Form>
|
</Form>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatDate(date?: Date) {
|
||||||
|
if (!date || isNaN(date as any)) date = new Date()
|
||||||
|
return date.toISOString().substring(0, 10)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user