From 87eb122ee87d6daaf0bc67d1cc9a6bdbc62a3294 Mon Sep 17 00:00:00 2001 From: Abhinav Ohri Date: Tue, 22 Sep 2026 16:27:42 +0530 Subject: [PATCH] fix(calendar): focus today in list view Assisted-by: Codex:gpt-5 Signed-off-by: Abhinav Ohri --- .../AppNavigationHeaderTodayButton.vue | 5 ----- src/components/CalendarGrid.vue | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/components/AppNavigation/AppNavigationHeader/AppNavigationHeaderTodayButton.vue b/src/components/AppNavigation/AppNavigationHeader/AppNavigationHeaderTodayButton.vue index 87dac58b8d..082b4e0bbe 100644 --- a/src/components/AppNavigation/AppNavigationHeader/AppNavigationHeaderTodayButton.vue +++ b/src/components/AppNavigation/AppNavigationHeader/AppNavigationHeaderTodayButton.vue @@ -13,11 +13,6 @@ const route = useRoute() const router = useRouter() async function today(): Promise { - // Don't push new route when day didn't change - if (route.params.firstDay === 'now') { - return - } - const name = route.name! const params = { ...route.params, diff --git a/src/components/CalendarGrid.vue b/src/components/CalendarGrid.vue index c151c27dd4..e72a59e985 100644 --- a/src/components/CalendarGrid.vue +++ b/src/components/CalendarGrid.vue @@ -23,6 +23,7 @@ import { DateTimeValue } from '@nextcloud/calendar-js' // Import other dependencies import debounce from 'debounce' import { mapState, mapStores } from 'pinia' +import { isNavigationFailure, NavigationFailureType } from 'vue-router' // Import event sources import eventSource from '@/fullcalendar/eventSources/eventSource.js' // Import interaction handlers @@ -301,6 +302,13 @@ export default { next() }) + // Navigating to the current route skips beforeEach but still triggers afterEach + this.$router.afterEach((to, from, failure) => { + if (isNavigationFailure(failure, NavigationFailureType.duplicated) && to.params.firstDay === 'now') { + this.scrollViewToToday(false) + } + }) + // Trigger the select event programmatically on initial page load to show the new event // in the grid. Wait for the next tick because the ref isn't available right away. await this.$nextTick() @@ -336,8 +344,15 @@ export default { } this.$nextTick(() => { const todayEl = this.$refs.fullCalendar.$el.querySelector('.fc-day-today') - if (todayEl) { - todayEl.scrollIntoView({ block: 'nearest', behavior: 'smooth' }) + if (calendarApi.view.type === 'dayGridMonth') { + if (todayEl) { + todayEl.scrollIntoView({ block: 'nearest', behavior: 'smooth' }) + } + } + if (calendarApi.view.type === 'listMonth') { + if (todayEl) { + todayEl.scrollIntoView({ block: 'start', behavior: 'smooth' }) + } } }) },