From 54ecf8d7ca7672f55e2b6aa30c0cab7f9c14d511 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Tue, 29 Oct 2024 15:16:42 +0000
Subject: [PATCH] Bug 37912: Restore detail-trigger handling

This patch converts our jQuery based click to native JS and restores the
bootstrap modal button click trigger handling.

Signed-off-by: Sam Sowanick <sam.sowanick@corvallisoregon.gov>
---
 .../prog/js/modals/display_ticket.js          | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js
index 43d32fd83e..faa19cef3a 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js
@@ -1,11 +1,20 @@
 /* keep tidy */
 $(document).ready(function () {
-    $("#table_concerns").on("click", ".detail-trigger", function () {
-        // Find the main trigger anchor within the same table row
-        var $mainTrigger = $(this).closest("tr").find(".main-trigger");
+    document.addEventListener("click", function (event) {
+        const detailTrigger = event.target.closest(".detail-trigger");
+        if (detailTrigger) {
+            event.preventDefault();
 
-        // Trigger the click event of the main trigger anchor
-        $mainTrigger.trigger("click");
+            // Find the main trigger button in the same row
+            const mainTrigger = detailTrigger
+                .closest("tr")
+                .querySelector(".main-trigger");
+
+            // Trigger a click on the main trigger if it exists
+            if (mainTrigger) {
+                mainTrigger.click();
+            }
+        }
     });
 
     $("#ticketDetailsModal").on("show.bs.modal", function (event) {
-- 
2.39.5