Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -645,7 +645,6 @@ export default function CalendarApp({
|
|||||||
}}
|
}}
|
||||||
datesSet={(arg) => {
|
datesSet={(arg) => {
|
||||||
setCurrentView(arg.view.type);
|
setCurrentView(arg.view.type);
|
||||||
// Get the current date from calendar API to ensure consistency
|
|
||||||
const calendarCurrentDate =
|
const calendarCurrentDate =
|
||||||
calendarRef.current?.getDate() || new Date(arg.start);
|
calendarRef.current?.getDate() || new Date(arg.start);
|
||||||
|
|
||||||
@@ -656,8 +655,8 @@ export default function CalendarApp({
|
|||||||
setSelectedDate(new Date(middle));
|
setSelectedDate(new Date(middle));
|
||||||
setSelectedMiniDate(calendarCurrentDate);
|
setSelectedMiniDate(calendarCurrentDate);
|
||||||
} else {
|
} else {
|
||||||
setSelectedDate(new Date(arg.start));
|
setSelectedDate(calendarCurrentDate);
|
||||||
setSelectedMiniDate(new Date(arg.start));
|
setSelectedMiniDate(calendarCurrentDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always use the calendar's current date for consistency
|
// Always use the calendar's current date for consistency
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
||||||
import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment";
|
import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment";
|
||||||
import { DateCalendar, PickersDay } from "@mui/x-date-pickers";
|
import { DateCalendar } from "@mui/x-date-pickers";
|
||||||
import { DayCalendarSkeleton } from "@mui/x-date-pickers/DayCalendarSkeleton";
|
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import {
|
import {
|
||||||
computeStartOfTheWeek,
|
computeStartOfTheWeek,
|
||||||
@@ -9,7 +8,6 @@ import {
|
|||||||
getCalendarRange,
|
getCalendarRange,
|
||||||
} from "../../utils/dateUtils";
|
} from "../../utils/dateUtils";
|
||||||
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
||||||
import { refreshCalendars } from "../Event/utils/eventUtils";
|
|
||||||
import { getCalendarDetailAsync } from "../../features/Calendars/CalendarSlice";
|
import { getCalendarDetailAsync } from "../../features/Calendars/CalendarSlice";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
||||||
@@ -40,12 +38,13 @@ export function MiniCalendar({
|
|||||||
>
|
>
|
||||||
<DateCalendar
|
<DateCalendar
|
||||||
value={moment(visibleDate)}
|
value={moment(visibleDate)}
|
||||||
onChange={(dateMoment) => {
|
onChange={(dateMoment, selectionState) => {
|
||||||
if (!dateMoment) return;
|
if (!dateMoment) return;
|
||||||
const date = dateMoment.toDate();
|
const date = dateMoment.toDate();
|
||||||
setSelectedDate(date);
|
if (selectionState === "finish") {
|
||||||
setSelectedMiniDate(date);
|
setSelectedMiniDate(date);
|
||||||
calendarRef.current?.gotoDate(date);
|
calendarRef.current?.gotoDate(date);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
showDaysOutsideCurrentMonth
|
showDaysOutsideCurrentMonth
|
||||||
onMonthChange={(month) => {
|
onMonthChange={(month) => {
|
||||||
@@ -112,11 +111,6 @@ export function MiniCalendar({
|
|||||||
selected: classNames.includes("selectedWeek"),
|
selected: classNames.includes("selectedWeek"),
|
||||||
outsideCurrentMonth: ownerState.isDayOutsideMonth,
|
outsideCurrentMonth: ownerState.isDayOutsideMonth,
|
||||||
disableMargin: false,
|
disableMargin: false,
|
||||||
onClick: () => {
|
|
||||||
setSelectedDate(date);
|
|
||||||
setSelectedMiniDate(date);
|
|
||||||
calendarRef.current?.gotoDate(date);
|
|
||||||
},
|
|
||||||
style: {
|
style: {
|
||||||
backgroundColor: "transparent",
|
backgroundColor: "transparent",
|
||||||
position: "relative",
|
position: "relative",
|
||||||
|
|||||||
Reference in New Issue
Block a user