From b150de8b6a49267a67ae63452c2933eeb01e4ec7 Mon Sep 17 00:00:00 2001 From: grgurmg <99843025+grgurmg@users.noreply.github.com> Date: Mon, 20 Oct 2025 14:14:55 -0400 Subject: [PATCH] Bug 41058: Assign timeout id when delaying issues table load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When AlwaysLoadCheckoutsTable is enabled and a delay is configured, we were calling setTimeout without capturing the returned id, despite a `loadIssuesTableDelayTimeoutId` variable already being declared and targetted by clearTimeout. This prevented the "Load now" button from properly clearing the pending timeout. Test plan: 1. Configure a delay (LoadCheckoutsTableDelay > 0) so checkouts table loads after N seconds. 2. Go to a patron’s checkouts page. 3. Before the delay completes, click "Load now". - Without this patch: an alert window will display a "Something went wrong when loading the table" error once the timeout triggers. - With this patch: the pending timeout is cleared; the table loads immediately only once. 4. Reload the page with the delay set; wait for the timeout to elapse and confirm the table loads normally. Signed-off-by: Mike Grgurev --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index ecf8409c02..93e386a721 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -751,7 +751,7 @@ var barcodefield = $("#barcode"); if (AlwaysLoadCheckoutsTable) { if (LoadCheckoutsTableDelay) { - setTimeout(function () { + loadIssuesTableDelayTimeoutId = setTimeout(function () { LoadIssuesTable(); }, LoadCheckoutsTableDelay * 1000); } else { @@ -774,7 +774,7 @@ if (AlwaysLoadCheckoutsTable) { if (Cookies.get("issues-table-load-immediately-" + script) == "true") { if (LoadCheckoutsTableDelay) { - setTimeout(function () { + loadIssuesTableDelayTimeoutId = setTimeout(function () { LoadIssuesTable(); }, LoadCheckoutsTableDelay * 1000); } else { -- 2.39.5