From 806593aca6d931349d2b789e60fbd1f23da8bf8d Mon Sep 17 00:00:00 2001 From: Eric Oulashin <nightfox@synchro.net> Date: Thu, 5 Sep 2024 06:27:17 +0000 Subject: [PATCH] dd_lightbar_menu.js: Fix for out-of-bounds row updates when updating the scrollbar in DDLightbarMenu_UpdateScrollbar() --- exec/load/dd_lightbar_menu.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/exec/load/dd_lightbar_menu.js b/exec/load/dd_lightbar_menu.js index f46e304949..704013e28a 100644 --- a/exec/load/dd_lightbar_menu.js +++ b/exec/load/dd_lightbar_menu.js @@ -3134,8 +3134,19 @@ function DDLightbarMenu_UpdateScrollbar(pNewStartRow, pOldStartRow, pNumSolidBlo // then the solid block section has moved down; if the diff is negative, the // solid block section has moved up. var solidBlockStartRowDiff = pNewStartRow - pOldStartRow; + // Calculate the 'old' last row & new last row, but don't let them go over + // the bottom row of the menu var oldLastRow = pOldStartRow + numSolidBlocks - 1; + const maxY = this.pos.y + this.size.height - 1; + if (oldLastRow > maxY) + oldLastRow = maxY; + else if (oldLastRow < this.pos.y) + oldLastRow = this.pos.y; var newLastRow = pNewStartRow + numSolidBlocks - 1; + if (newLastRow > maxY) + newLastRow = maxY; + else if (newLastRow < this.pos.y) + newLastRow = this.pos.y; if (solidBlockStartRowDiff > 0) { // The solid block section has moved down -- GitLab