tldr; Looking for some context around the assignment similar to h = this._cols[d].date,
in scrollToTime in v5.33.0. Confirming that cols refers to resource columns.
Recently upgraded to 5.33.0 and started hitting this in one of my tests for a scheduler view I have. I don’t actually hit this error when using the application, so I’m probably either not providing all the data in the test.
The test is wonky in that even though I have at least one resource and 1 event that matches that resource, the event isn’t rendered (or possibly rendering is delayed or occurs after this error occurs)
My issue is it’s not easy for me to tell what data this is aside from it’s an undefined col from looking at the minified code.
The error in the topic subject occurs at the line in the first if branch h = this._cols[d].date,
. Changing this to h = this._cols[d]?.date,
but I don’t no if it’s correct that this can ever be false without more context.
I worked around this by setting initial state and only looking at whether a spy got called via msw, but I’d rather wait for the event to show up in the ui.
Here are the two versions _scrollToTime. Most of the diff are variable name changes due to minification.
// v 5.32.2 (Works)
_scrollToTime = function (e) {
var t = this,
a = this._scrollCont,
n = this._gridCont,
s = this._isTimeline;
if (a) {
var i = this.s,
r = this._hasResY,
o = i.navigateToEvent,
l = o && o.start ? new Date(+Gt(o.start, i)) : new Date(i.selected),
c = this._colIndexMap[Rt(l)];
c === ue ||
!s ||
r ||
("hour" === i.resolution && this._stepCell !== Tt && !i.eventList)
? l.setHours(i.eventList ? 0 : l.getHours(), 0, 0, 0)
: (l = this._cols[c].date);
var d = jr(l, this._startTime, this._time * (s ? this._daysNr : 1)),
h = r ? 0 : Vt(this._firstDay, l, i.startDay, i.endDay),
u =
((s ? n.offsetWidth : n.scrollWidth) *
((100 * h) / this._daysNr + (s ? d : 0))) /
100 +
1,
m = void 0;
if (o || r) {
var _ = this._visibleResources,
p = o ? o.resource : _[0].id,
v = ge(p) ? p[0] : p;
if (v !== ue)
if (s) {
var f = (r ? Rt(l) + "-" : "") + v;
m = this._resourceTops[f];
} else {
var g = this._colWidth,
y =
Re(_, function (e) {
return e.id === v;
}) || 0;
u =
this._groupByResource && !this._isSingleResource
? this._daysNr * g * y + g * h
: _.length * h * g + y * g;
}
}
if (!s) {
var b = a.querySelector(".mbsc-schedule-column-inner");
(m = b ? (b.offsetHeight * d) / 100 : 0),
!this._groupByResource || this._isSingleResource || o || (u = ue);
}
this._isScrolling
? this._isScrolling(u, m)
: (this._isScrolling = Fa(a, u, m, e, i.rtl, function () {
setTimeout(function () {
t._isScrolling = ue;
}, 150);
}));
}
};
// v 5.33.0 (Doesn't Work)
_scrollToTime = function (e, t) {
var a = this,
n = this._scrollCont,
s = this._gridCont,
i = this._isTimeline;
if (n) {
var r = this.s,
o = this._hasResY,
l = r.navigateToEvent,
c = l && l.start ? new Date(+Gt(l.start, r)) : new Date(r.selected),
d = this._colIndexMap[Ot(c)],
h = this._cols[d].date,
u =
i &&
!o &&
h &&
("month" === r.resolution || "quarter" === r.resolution);
t ||
(i &&
!o &&
h &&
("hour" !== r.resolution || this._stepCell === St || r.eventList)
? (c = h)
: c.setHours(r.eventList ? 0 : c.getHours(), 0, 0, 0));
var m = Kr(c, this._startTime, this._time * (i ? this._daysNr : 1)),
_ = u ? d : o ? 0 : Pt(this._firstDay, c, r.startDay, r.endDay),
p = u ? this._colsNr : this._daysNr,
v =
((i ? s.offsetWidth : s.scrollWidth) * ((100 * _) / p + (i ? m : 0))) /
100 -
(t ? this.state.gridContWidth / 2 : 0) +
1,
f = void 0;
if (l || o) {
var g = this._visibleResources,
y = l ? l.resource : g[0].id,
b = ye(y) ? y[0] : y;
if (b !== me)
if (i) {
var x = (o ? Ot(c) + "-" : "") + b;
f = this._resourceTops[x];
} else {
var D = this._colWidth,
T =
Oe(g, function (e) {
return e.id === b;
}) || 0;
v =
this._groupByResource && !this._isSingleResource
? p * D * T + D * _
: g.length * _ * D + T * D;
}
}
if (i) this._setViewDates(v);
else {
var S = n.querySelector(".mbsc-schedule-column-inner");
(f = S ? (S.offsetHeight * m) / 100 : 0),
!this._groupByResource || this._isSingleResource || l || (v = me);
}
this._isScrolling
? this._isScrolling(v, f)
: (this._isScrolling = Fa(n, v, f, e, r.rtl, function () {
setTimeout(function () {
a._isScrolling = me;
}, 150);
}));
}
};