Skip to content

Commit a1b2200

Browse files
committed
fix: don't allow sizing end to midnight from next day
1 parent ffb5fc1 commit a1b2200

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/components/Day.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
import DayEvent from "./DayEvent.vue";
5353
import { $CalendarEvent } from "../types/interfaces";
5454
import { computed, onMounted, onUnmounted, ref } from "vue";
55-
import { isSameDay, isToday } from "date-fns";
55+
import { isSameDay, isAfter } from "date-fns";
5656
import {
5757
calculatePositions,
5858
processConcurrency,
@@ -90,7 +90,11 @@ onUnmounted(() => {
9090
const isDateToday = computed(() => isSameDay(now.value, props.date));
9191
9292
const filteredEvents = computed(() => {
93-
let filtered = props.events.filter((e) => isSameDay(e.startDate, props.date) || isSameDay(e.endDate, props.date));
93+
let filtered = props.events.filter(
94+
(e) =>
95+
isSameDay(e.startDate, props.date) ||
96+
(isSameDay(e.endDate, props.date) && isAfter(e.endDate, props.date))
97+
);
9498
return props.concurrencyMode == "stack"
9599
? processConcurrency(filtered)
96100
: calculatePositions(filtered);

src/components/Week.vue

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ import {
192192
addMinutes,
193193
endOfDay,
194194
isAfter,
195+
isBefore,
195196
startOfDay,
196197
differenceInCalendarDays,
197198
addDays,
@@ -338,14 +339,23 @@ function onMouseMove(mouseEvent: MouseEvent) {
338339
: [newTime, anchor];
339340
340341
const mouseDownColumnDate = getDateFromX(startX);
341-
let max = isSameDay(mouseDownColumnDate, initialState.endDate)
342-
? endOfDay(mouseDownColumnDate)
343-
: startOfDay(addDays(initialState.startDate, 1));
344-
max = addHours(max, props.hoursPastMidnight);
342+
343+
let max: Date;
344+
if (isSameDay(mouseDownColumnDate, initialState.endDate)) {
345+
max = endOfDay(mouseDownColumnDate);
346+
} else {
347+
max = startOfDay(addDays(initialState.startDate, 1));
348+
max = addHours(max, props.hoursPastMidnight);
349+
}
345350
346351
if (
347352
!isSameDay(startDate, initialState.startDate) ||
348-
isAfter(endDate, max)
353+
isAfter(endDate, max) ||
354+
(mouseDown.handle == "bottom" &&
355+
isBefore(
356+
endDate,
357+
addMinutes(mouseDownColumnDate, props.intervalMinutes)
358+
))
349359
) {
350360
return;
351361
}

0 commit comments

Comments
 (0)