1

According to the .getEvents() documentation, it should return "all events in memory", but when having simple recurring events outside the current view, it doesn't.

No matter if they are dynamically added via calendar.addEvent() or are loaded with the events/ initialEvents option. It also happens with any view (I've tried timeGrid, dayGrid and dayGridMonth), while normal events not in the view do get returned as expected.

This behavior happens (at least) both in 5 (5.10.1 to be exact) and 6 (6.1.6).

Here is a reproducer, it's pretty simple but works like this: The calendar is initialized to Jan 2023 and then normal and recurring events are added in May and Jun so they are not showing in the current view. getEvents returns the May one (the normal one) but not the recurrings.

var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
  initialView: 'dayGridMonth',
  initialDate: '2023-01-01'
});
calendar.render();
console.log('Current View: ' + calendar.view.title)

console.log('Adding normal event')
calendar.addEvent({
  title: 'Normal Event',
  start: '2023-04-03T17:00:00',
  end: '2023-04-07T17:30:00'
})
console.log(`Found: ${calendar.getEvents().length}, 1 expected`)
console.log('Adding recurring event')
calendar.addEvent({
  title: 'Recurring Event',
  startTime: '17:00:00',
  endTime: '17:30:00',
  startRecur: '2023-06-07',
  endRecur: '2023-06-22',
  daysOfWeek: [3] // Wed
});
// Recurring events are expanded, so we expect 4, not 2. I can filter individual events based on the `defId`...
// ... if only I could get them
console.log(`Found: ${calendar.getEvents().length}, 4 expected!`)

calendar.gotoDate('2023-06-01')
console.log('Current View: ' + calendar.view.title)
console.log(`Found: ${calendar.getEvents().length}, 4 expected`)
<script src="https://cdn.jsdelivr.net/npm/@fullcalendar/core@6.1.6/index.global.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@fullcalendar/daygrid@6.1.6/index.global.min.js"></script>
<div id="calendar"></div>

There is a similar question regarding previous view-dependent bugs, but I'm surprised noone has run into this before. Is this behavior documented anywhere or am I correct in thinking this may be a bug?

I can muck around with the eventStore, but it can get really ugly when having multiple eventSources. Is there any API alternative to get all events? (ideally, unique ones i.e. the defs and not the instances themselves; but this is not a dealbreaker as I can filter them easily).

msg
  • 7,863
  • 3
  • 14
  • 33
  • We can't really comment on whether the behaviour is intentional as (AFAIK) no-one here who watches the fullCalendar tag is actually a fullCalendar developer (and as you say, the documentation is not informative on this specific point). However it does feel like a bug, so I suggest going to https://fullcalendar.io/reporting-bugs – ADyson Apr 28 '23 at 19:06

0 Answers0