Skip to content

Commit

Permalink
always refetch when a date nav invalidates an in-progress event sourc…
Browse files Browse the repository at this point in the history
…e fetch
  • Loading branch information
arshaw committed Feb 11, 2020
1 parent f1bd50b commit e162199
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
45 changes: 45 additions & 0 deletions packages/__tests__/src/event-source/navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

describe('event fetching while date-navigating', function() {

// https://github.com/fullcalendar/fullcalendar/issues/4975
it('renders events when doing next() and then prev()', function(done) {

initCalendar({
defaultView: 'dayGridMonth',
defaultDate: '2020-02-11',
events: function(arg, callback) {
if (arg.startStr.indexOf('2020-01-26') === 0) { // for Feb
setTimeout(function() {
callback([
{ start: '2020-02-15' } // middle of month
])
}, 100)
} else if (arg.startStr.indexOf('2020-03-01') === 0) { // for March
setTimeout(function() {
callback([
{ start: '2020-03-15' } // middle of month
])
}, 100)
} else {
throw new Error('bad range')
}
}
})

setTimeout(function() {

currentCalendar.next()
setTimeout(function() {

currentCalendar.prev()
setTimeout(function() {

expect($('.fc-event').length).toBe(1)
done()

}, 1000) // after everything
}, 50) // before second fetch finishes
}, 200) // let first fetch finish
})

})
1 change: 1 addition & 0 deletions packages/core/src/reducers/eventSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function isSourceDirty(eventSource: EventSource, fetchRange: DateRange, calendar
} else {
return !calendar.opt('lazyFetching') ||
!eventSource.fetchRange ||
eventSource.isFetching || // always cancel outdated in-progress fetches
fetchRange.start < eventSource.fetchRange.start ||
fetchRange.end > eventSource.fetchRange.end
}
Expand Down

0 comments on commit e162199

Please sign in to comment.