Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable4.7] fix: delay initializing the resize observer until FC is ready #5997

Closed
wants to merge 1 commit into from
Closed
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
30 changes: 30 additions & 0 deletions src/components/CalendarGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,36 @@ export default {
this.$store.dispatch('setInitialView', { initialView })
}
}, 5000),

/**
* Called once when FullCalendar is ready. This event is delayed until the component is
* mounted and its ref is available.
*/
onFullCalendarReady() {
/**
* FullCalendar 5 is using calculated px values for the width
* of its views.
* Hence a simple `width: 100%` won't assure that the calendar-grid
* is always using the full available width.
*
* Toggling the AppNavigation or AppSidebar will change the amount
* of available space, but it will not be covered by the window
* resize event, because the actual window size did not change.
*
* To make sure, that the calendar-grid is always using all space,
* we have to register a resize-observer here, that will automatically
* update the fullCalendar size, when the available space changes.
*/
if (window.ResizeObserver) {
const resizeObserver = new ResizeObserver(debounce(() => {
this.$refs.fullCalendar
.getApi()
.updateSize()
}, 100))

resizeObserver.observe(this.$refs.fullCalendar.$el)
}
},
},
}
</script>
Expand Down