Skip to content

Commit

Permalink
fix: time setting for adding events not working
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJustChew committed Oct 1, 2024
1 parent 7230a0e commit 3628fdd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/Calendar/AddEventButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down Expand Up @@ -248,7 +251,17 @@ export const AddEventButton = ({
<FormItem>
<Input
type="time"
onChange={field.onChange}
onChange={(v) => {
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")}
/>
<FormMessage />
Expand Down

0 comments on commit 3628fdd

Please sign in to comment.