fix: guard changeFilters against invalid date input in montagereview

When the datetime picker closed with an empty or malformed value,
DateTime.fromFormat returned an Invalid DateTime and .valueOf() gave
NaN.  That NaN propagated through minTimeSecs/rangeTimeSecs into
drawSliderOnGraph, where parseInt(NaN) yielded a NaN sliderX and
getImageData rejected it with "Value is not of type 'long'".

Return early from changeFilters when either parsed DateTime is
invalid so the NaN never reaches the canvas.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Isaac Connor
2026-04-18 09:52:26 -04:00
parent f91abd81cd
commit 0cc561dadd

View File

@@ -1097,6 +1097,14 @@ function changeFilters(e) {
let minStartDateTime = DateTime.fromFormat(minStartDateTimeElement.value, 'yyyy-MM-dd HH:mm:ss', {zone: ZM_TIMEZONE});
let maxStartDateTime = DateTime.fromFormat(maxStartDateTimeElement.value, 'yyyy-MM-dd HH:mm:ss', {zone: ZM_TIMEZONE});
// If either input is empty or malformed, bail out rather than letting
// NaN propagate into minTimeSecs/rangeTimeSecs and crash getImageData
// in drawSliderOnGraph.
if (!minStartDateTime.isValid || !maxStartDateTime.isValid) {
console.warn("changeFilters: invalid date input, skipping update");
return;
}
if (this === minStartDateTimeElement) {
if (minStartDateTime > maxStartDateTime) {
maxStartDateTime = minStartDateTime.plus({hours: 1}); // Maybe leave a gap?