From 94450c98be5811752621dbde20b19817f68f3a9f Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 7 Oct 2024 15:50:39 +0000 Subject: [PATCH] Bug 38072: Ensure the printing tab closes Signed-off-by: David Nind --- koha-tmpl/intranet-tmpl/prog/js/modal_printer.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js b/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js index ac562c7056..ea1608111a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js @@ -41,12 +41,13 @@ $(document).ready(function () { win.document.write(title); win.document.write(contents); win.document.close(); - win.focus(); - win.print(); - win.onafterprint = function () { + win.addEventListener( 'afterprint', function () { + win.addEventListener( 'focus', function () { + win.close(); + }); win.close(); - } - setTimeout('window.close()', 1000); //Hack from Chrome < 63 + }); + win.print(); } // Set focused on printable modals on open and autoprint if required -- 2.39.5