From 64eb7cca038e789eb6a59bd4d79df2c60e1dd72d 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 | 13 +++++++------ 1 file changed, 7 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 b93b82e62c..b199a6699a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js @@ -38,16 +38,17 @@ $(document).ready(function() { text-align: left; } - `) + `); 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.47.0