From d2bcbd7a57ee9a051221a8646cf497e4e48607ed Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Tue, 20 Feb 2024 07:15:44 +0000 Subject: [PATCH] fix(nc-gui): better handling of date change --- .../nc-gui/components/nc/DateWeekSelector.vue | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/components/nc/DateWeekSelector.vue b/packages/nc-gui/components/nc/DateWeekSelector.vue index 7751280868..26941283f5 100644 --- a/packages/nc-gui/components/nc/DateWeekSelector.vue +++ b/packages/nc-gui/components/nc/DateWeekSelector.vue @@ -7,6 +7,7 @@ interface Props { activeDates?: Date[]; isMondayFirst?: boolean; weekPicker?: boolean; + disablePagination?: boolean; selectedWeek?: { start: Date; end: Date; @@ -20,6 +21,7 @@ const props = withDefaults(defineProps(), { isMondayFirst: false, pageDate: new Date(), weekPicker: false, + disablePagination: false, activeDates: [], selectedWeek: null, }); @@ -84,11 +86,19 @@ const isSelectedDate = (dObj: Date) => { return props.selectedDate ? isSameDate(propDate, dObj) : false; } +const isDayInPagedMonth = (date: Date) => { + return date.getMonth() === pageDate.value.getMonth(); +} + // Since we are using the same component for week picker and date picker we need to handle the date selection differently const handleSelectDate = (date: Date) => { if (props.weekPicker) { selectWeek(date); } else { + if (!isDayInPagedMonth(date)) { + pageDate.value = new Date(date); + emit('update:page-date', date); + } selectedDate.value = date; emit('update:selected-date', date); } @@ -124,16 +134,20 @@ const paginate = (action: 'next' | 'prev') => { emit('update:page-date', newDate); }; +