Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
const route = useRoute()
const router = useRouter()

async function today(): Promise<void> {

Check warning on line 15 in src/components/AppNavigation/AppNavigationHeader/AppNavigationHeaderTodayButton.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc comment
// Don't push new route when day didn't change
if (route.params.firstDay === 'now') {
return
}

const name = route.name!
const params = {
...route.params,
Expand Down
19 changes: 17 additions & 2 deletions src/components/CalendarGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -302,6 +303,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()
Expand Down Expand Up @@ -335,8 +343,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' })
}
}
})
},
Expand Down
Loading