From b7d3110d131f63c846f87cf783f2d77eaff48938 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Fri, 29 Mar 2024 05:23:04 +0000 Subject: [PATCH] fix(nc-gui): improved auto scroll --- .../smartsheet/calendar/DayView/DateTimeField.vue | 6 ++++-- .../smartsheet/calendar/WeekView/DateTimeField.vue | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue index 2c4c025d6c..88323bb734 100644 --- a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue @@ -848,7 +848,9 @@ watch( () => { setTimeout(() => { if (isDragging.value) return - document.querySelectorAll('.draggable-record').item(0)?.scrollIntoView({ behavior: 'smooth', block: 'center' }) + const records = document.querySelectorAll('.draggable-record') + if (records.length) records.item(0)?.scrollIntoView({ behavior: 'smooth', block: 'center' }) + else document.querySelectorAll('.nc-calendar-day-hour').item(9)?.scrollIntoView({ behavior: 'smooth', block: 'center' }) }, 100) }, { immediate: true }, @@ -867,7 +869,7 @@ watch( :class="{ '!border-brand-500': hour.isSame(selectedTime), }" - class="flex w-full h-15 relative border-1 group hover:bg-gray-50 border-white border-b-gray-100" + class="flex w-full h-15 nc-calendar-day-hour relative border-1 group hover:bg-gray-50 border-white border-b-gray-100" data-testid="nc-calendar-day-hour" @click="selectHour(hour)" @dblclick="newRecord(hour)" diff --git a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue index ea23ddc272..d54697da18 100644 --- a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue @@ -722,7 +722,9 @@ watch( () => recordsAcrossAllRange.value, () => { if (dragRecord.value) return - document.querySelectorAll('.draggable-record').item(0)?.scrollIntoView({ behavior: 'smooth', block: 'center' }) + const records = document.querySelectorAll('.draggable-record') + if (records.length) records.item(0)?.scrollIntoView({ behavior: 'smooth', block: 'center' }) + else document.querySelectorAll('.nc-calendar-day-hour').item(9)?.scrollIntoView({ behavior: 'smooth', block: 'center' }) }, { immediate: true }, ) @@ -751,7 +753,7 @@ watch(
{{ hour.format('h A') }}