[fix] bug where mini calendar doesnt follow full one when week goes from one month to another

This commit is contained in:
Camille Moussu
2025-07-24 10:59:28 +02:00
committed by Benoit TELLIER
parent 432b626be4
commit cac89e7d02
2 changed files with 14 additions and 9 deletions
@@ -219,4 +219,17 @@ describe("Found Bugs", () => {
expect(weekViewSelectedTiles).toHaveLength(7);
});
it("gray day stays when day mode, change day, then change to week view", async () => {
jest.useFakeTimers().setSystemTime(new Date("2025-01-30"));
renderCalendar();
const nextWeekButton = screen.getByTitle("Next week");
fireEvent.click(nextWeekButton);
const miniCalMonth = await screen.findByTitle(/mini calendar month/i);
const fullCalMonth = screen.getByText((content, element) => {
return element?.className.includes("fc-toolbar-title") ?? false;
});
expect(miniCalMonth.innerHTML).toBe(fullCalMonth.innerHTML);
});
});
+1 -9
View File
@@ -238,15 +238,7 @@ export default function CalendarApp() {
hour12: false,
}}
datesSet={(arg) => {
if (arg.view.type === "timeGridDay") {
setSelectedDate(new Date(arg.start));
setSelectedMiniDate(new Date(arg.start));
} else if (arg.view.type === "timeGridWeek") {
if (selectedDate <= arg.start && selectedDate >= arg.end) {
setSelectedMiniDate(new Date(arg.start));
}
setSelectedDate(new Date(arg.start));
} else if (arg.view.type === "dayGridMonth") {
if (arg.view.type === "dayGridMonth") {
setSelectedDate(new Date(arg.start));
const midTimestamp =
(arg.start.getTime() + arg.end.getTime()) / 2;