From 339c5f73b033efb765c13436d2ab3333dcceb2da Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 3 Oct 2024 15:41:05 +0100 Subject: [PATCH] Bug 38072: Fix regression in modal_printer This patch updates the JS for the modal printer to make it more reliable. I found that in recent versions of chrome the print dialog failed to open and instead you were just faced with a flash of white before the new tab autoclosed and no print takes place. Test plan 1) Enable cash registers and point of sale preferences 2) Add a debit type and mark it as 'Can be sold' 3) Add a cash register 4) Use 'Point of sale' to sell one of the above item for cash against the register you just created. 5) Navigate to the register and 'cashup' 6) Click the 'summary' link to display a modal 7) User the 'Print' option in the modal and confirm you face a print dialog and can print --- koha-tmpl/intranet-tmpl/prog/js/modal_printer.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js b/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js index 42289b8d3f3..599cb92a45e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js @@ -41,13 +41,12 @@ $(document).ready(function () { win.document.write(title); win.document.write(contents); win.document.close(); - win.addEventListener("afterprint", function () { - win.addEventListener("focus", function () { - win.close(); - }); - win.close(); - }); + win.focus(); win.print(); + win.onafterprint = function () { + win.close(); + }; + setTimeout("window.close()", 1000); //Hack from Chrome < 63 } // Set focused on printable modals on open and autoprint if required -- 2.53.0