2
0
Эх сурвалжийг харах

solve JS errors when switching views and using showNonCurrentDates. closes #4677. closes #4767

Adam Shaw 6 жил өмнө
parent
commit
b64b59360c

+ 1 - 0
CHANGELOG.md

@@ -2,6 +2,7 @@
 next
 next
 ----
 ----
 
 
+- solve JS errors when switching views and using showNonCurrentDates (#4677, #4767)
 - prevent unnecessary scrollbars from appearing in daygrid views (4624, #4732)
 - prevent unnecessary scrollbars from appearing in daygrid views (4624, #4732)
 - draggedEvent start time is null in eventAllow when switching resources (#4932)
 - draggedEvent start time is null in eventAllow when switching resources (#4932)
 - scrollToTime method honors a whole duration, not just a time (#4935)
 - scrollToTime method honors a whole duration, not just a time (#4935)

+ 21 - 0
packages/__tests__/src/view-render/showNonCurrentDates.js

@@ -29,4 +29,25 @@ describe('showNonCurrentDates', function() {
       expectDayRange('2017-05-28', '2017-06-04')
       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')
+  })
+
 })
 })

+ 12 - 2
packages/core/src/DateProfileGenerator.ts

@@ -447,10 +447,20 @@ export default class DateProfileGenerator {
 
 
 }
 }
 
 
+
 // TODO: find a way to avoid comparing DateProfiles. it's tedious
 // TODO: find a way to avoid comparing DateProfiles. it's tedious
 export function isDateProfilesEqual(p0: DateProfile, p1: DateProfile) {
 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.minTime, p1.minTime) &&
     durationsEqual(p0.maxTime, p1.maxTime)
     durationsEqual(p0.maxTime, p1.maxTime)
+  /*
+  TODO: compare more?
+    currentRange: DateRange
+    currentRangeUnit: string
+    isRangeAllDay: boolean
+    isValid: boolean
+    dateIncrement: Duration
+  */
 }
 }