Skip to content

Commit 79264dd

Browse files
author
Dohyung Ahn
committed
fix: check prev & next date including month and year
1 parent 85b612b commit 79264dd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

apps/calendar/src/hooks/timeGrid/useTimeGridEventMove.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ function getMovingEventPosition({
4848
const startIndex = Math.max(getCurrentIndexByTime(nextStart, hourStart), 0);
4949
const endIndex = Math.min(getCurrentIndexByTime(nextEnd, hourStart), timeGridDataRows.length - 1);
5050

51-
const isStartAtPrevDate = nextStart.getDate() < currentDate.getDate();
52-
const isEndAtNextDate = nextEnd.getDate() > currentDate.getDate();
51+
const isStartAtPrevDate =
52+
nextStart.getFullYear() < currentDate.getFullYear() ||
53+
nextStart.getMonth() < currentDate.getMonth() ||
54+
nextStart.getDate() < currentDate.getDate();
55+
const isEndAtNextDate =
56+
nextEnd.getFullYear() > currentDate.getFullYear() ||
57+
nextEnd.getMonth() > currentDate.getMonth() ||
58+
nextEnd.getDate() > currentDate.getDate();
5359
const indexDiff = endIndex - (isStartAtPrevDate ? 0 : startIndex);
5460

5561
const top = isStartAtPrevDate ? 0 : timeGridDataRows[startIndex].top;

0 commit comments

Comments
 (0)