From f03d60213981bcc116d8eb456fcb7e311b6570a8 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 --- 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 ac562c70569..ea1608111a6 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