From 3628fdd4519f11d84ac9859efbdf10301027367a Mon Sep 17 00:00:00 2001 From: ImJustChew Date: Tue, 1 Oct 2024 23:12:38 +0900 Subject: [PATCH] fix: time setting for adding events not working --- src/components/Calendar/AddEventButton.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/Calendar/AddEventButton.tsx b/src/components/Calendar/AddEventButton.tsx index 7386bde3..b10d5ccb 100644 --- a/src/components/Calendar/AddEventButton.tsx +++ b/src/components/Calendar/AddEventButton.tsx @@ -220,6 +220,9 @@ export const AddEventButton = ({ type="time" onChange={(e) => { const timesplits = e.target.value.split(":"); + // ensure completed input before setting + if (timesplits[0].length < 2 || timesplits[1].length < 2) + return; const d = set(field.value, { hours: parseInt(timesplits[0]), minutes: parseInt(timesplits[1]), @@ -248,7 +251,17 @@ export const AddEventButton = ({ { + const timesplits = v.target.value.split(":"); + // ensure completed input before setting + if (timesplits[0].length < 2 || timesplits[1].length < 2) + return; + const d = set(field.value, { + hours: parseInt(timesplits[0]), + minutes: parseInt(timesplits[1]), + }); + field.onChange(d); + }} value={format(field.value, "HH:mm")} />