From 7fb7c76e2105e9761d12cfd32b83861b36c16848 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 28 Feb 2024 10:11:39 +0000 Subject: [PATCH] feat(nc-gui): scroll to active date in year view --- packages/nc-gui/components/nc/DateWeekSelector.vue | 2 +- packages/nc-gui/components/smartsheet/calendar/MonthView.vue | 4 ++-- .../smartsheet/calendar/WeekView/DateTimeField.vue | 2 +- packages/nc-gui/components/smartsheet/calendar/index.vue | 5 +++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/nc/DateWeekSelector.vue b/packages/nc-gui/components/nc/DateWeekSelector.vue index 7eb99b2d83..fbc3cd604e 100644 --- a/packages/nc-gui/components/nc/DateWeekSelector.vue +++ b/packages/nc-gui/components/nc/DateWeekSelector.vue @@ -180,7 +180,7 @@ const paginate = (action: 'next' | 'prev') => { 'text-gray-400': !isDateInCurrentMonth(date), 'nc-selected-week-start': isSameDate(date, selectedWeek?.start), 'nc-selected-week-end': isSameDate(date, selectedWeek?.end), - 'rounded-md bg-brand-50 text-brand-500': isSameDate(date, dayjs()) && isDateInCurrentMonth(date), + 'rounded-md bg-brand-50 nc-calendar-today text-brand-500': isSameDate(date, dayjs()) && isDateInCurrentMonth(date), }" class="h-9 w-9 px-1 py-2 relative font-medium flex items-center cursor-pointer justify-center" data-testid="nc-calendar-date" diff --git a/packages/nc-gui/components/smartsheet/calendar/MonthView.vue b/packages/nc-gui/components/smartsheet/calendar/MonthView.vue index ffd9fa2adc..be6ec75ea6 100644 --- a/packages/nc-gui/components/smartsheet/calendar/MonthView.vue +++ b/packages/nc-gui/components/smartsheet/calendar/MonthView.vue @@ -497,7 +497,7 @@ const onResizeEnd = () => { const onResizeStart = (direction: 'right' | 'left', event: MouseEvent, record: Row) => { if (!isUIAllowed('dataEdit') || draggingId.value) return - selectedDate.value = null + // selectedDate.value = null resizeInProgress.value = true resizeDirection.value = direction resizeRecord.value = record @@ -556,7 +556,7 @@ const dragStart = (event: MouseEvent, record: Row) => { }) dragRecord.value = record - selectedDate.value = null + // selectedDate.value = null isDragging.value = true dragElement.value = target diff --git a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue index b1803ac78a..dc92bedf0f 100644 --- a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue @@ -192,7 +192,7 @@ const recordsAcrossAllRange = computed<{ // We calculate the index of the hour in the day and set the top and height of the record const hourIndex = Math.min( Math.max( - datesHours.value[dayIndex].findIndex((h) => h.startOf('hour').format('HH:mm') === hourKey), + datesHours.value[dayIndex]?.findIndex((h) => h.startOf('hour').format('HH:mm') === hourKey), 0, ), 23, diff --git a/packages/nc-gui/components/smartsheet/calendar/index.vue b/packages/nc-gui/components/smartsheet/calendar/index.vue index 86058130b9..e4c3f3ae9a 100644 --- a/packages/nc-gui/components/smartsheet/calendar/index.vue +++ b/packages/nc-gui/components/smartsheet/calendar/index.vue @@ -140,6 +140,11 @@ const goToToday = () => { start: dayjs().startOf('week'), end: dayjs().endOf('week'), } + + document?.querySelector('.nc-calendar-today')?.scrollIntoView({ + behavior: 'smooth', + block: 'center', + }) } const headerText = computed(() => {