From 408c1ea9a4801969c437d8ecbe52be41822faa15 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Fri, 27 Jan 2023 18:24:24 -0400 Subject: [PATCH] fix: Show overfull style based on max, not sum, of session durations (#5044) * fix: Show overfull style based on max, not sum, of session durations * style: Avoid shadowing 'sessions' from outer scope --- ietf/static/js/edit-meeting-schedule.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ietf/static/js/edit-meeting-schedule.js b/ietf/static/js/edit-meeting-schedule.js index cf0bd364cf..21fc284ca1 100644 --- a/ietf/static/js/edit-meeting-schedule.js +++ b/ietf/static/js/edit-meeting-schedule.js @@ -647,12 +647,9 @@ $(function () { function updateTimeSlotDurationViolations() { timeslots.each(function () { - let total = 0; - jQuery(this).find(".session").each(function () { - total += +jQuery(this).data("duration"); - }); - - jQuery(this).toggleClass("overfull", total > +jQuery(this).data("duration")); + const sessionsInSlot = Array.from(this.getElementsByClassName('session')); + const requiredDuration = Math.max(sessionsInSlot.map(elt => Number(elt.dataset.duration))); + this.classList.toggle('overfull', requiredDuration > Number(this.dataset.duration)); }); }