Skip to content

Commit

Permalink
solve JS errors when switching views and using showNonCurrentDates. c…
Browse files Browse the repository at this point in the history
…loses #4677. closes #4767
  • Loading branch information
arshaw committed Aug 7, 2019
1 parent 234cb9f commit b64b593
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
next
----

- solve JS errors when switching views and using showNonCurrentDates (#4677, #4767)
- prevent unnecessary scrollbars from appearing in daygrid views (4624, #4732)
- draggedEvent start time is null in eventAllow when switching resources (#4932)
- scrollToTime method honors a whole duration, not just a time (#4935)
Expand Down
21 changes: 21 additions & 0 deletions packages/__tests__/src/view-render/showNonCurrentDates.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,25 @@ describe('showNonCurrentDates', function() {
expectDayRange('2017-05-28', '2017-06-04')
})
})

it('works when disabling weekends and switching views', function() {
initCalendar({
weekends: false,
defaultView: 'dayGridMonth',
defaultDate: '2019-06-07' // only shows problem when start date is a weekend!
})
currentCalendar.next()
currentCalendar.setOption('weekends', true)
// no errors thrown, yay
})

it('works when switching views with same formal duration but different rendered duration', function() {
initCalendar({
defaultView: 'listMonth', // something other than than dayGridMonth
defaultDate: '2019-01-01'
})
currentCalendar.changeView('dayGridMonth')
expectDayRange('2019-01-01', '2019-02-01')
})

})
14 changes: 12 additions & 2 deletions packages/core/src/DateProfileGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,20 @@ export default class DateProfileGenerator {

}


// TODO: find a way to avoid comparing DateProfiles. it's tedious
export function isDateProfilesEqual(p0: DateProfile, p1: DateProfile) {
return rangesEqual(p0.activeRange, p1.activeRange) &&
rangesEqual(p0.validRange, p1.validRange) &&
return rangesEqual(p0.validRange, p1.validRange) &&
rangesEqual(p0.activeRange, p1.activeRange) &&
rangesEqual(p0.renderRange, p1.renderRange) &&
durationsEqual(p0.minTime, p1.minTime) &&
durationsEqual(p0.maxTime, p1.maxTime)
/*
TODO: compare more?
currentRange: DateRange
currentRangeUnit: string
isRangeAllDay: boolean
isValid: boolean
dateIncrement: Duration
*/
}

0 comments on commit b64b593

Please sign in to comment.