Skip to content

Commit aae73f9

Browse files
committed
fix: ensure start date and end date is not the same when resizing allday events
1 parent 5e82182 commit aae73f9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/web/src/views/Calendar/components/Draft/hooks/actions/useDraftActions.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,21 @@ export const useDraftActions = (
567567
}
568568

569569
setDraft((_draft): Schema_GridEvent => {
570-
return {
570+
const result = {
571571
..._draft!,
572572
...(dateChanged ? { [dateChanged]: updatedTime } : {}),
573573
};
574+
575+
// All-day events end the day prior (EG: selected end date is "2020-01-01" but sent end date is "2020-01-02")
576+
// Ensure that we would never have all day events that start and end in the same day, for consistency purposes.
577+
// and less debugging headaches.
578+
if (result.startDate === result.endDate) {
579+
result.endDate = dayjs(result.endDate)
580+
.add(1, "day")
581+
.format("YYYY-MM-DD");
582+
}
583+
584+
return result;
574585
});
575586
},
576587
[

0 commit comments

Comments
 (0)