Description
Lucas Gass (lukeg)
2019-11-18 17:07:39 UTC
Which versions? Looks ok for me on Chrome 60.0.3112.113 and Chromium 73.0.3683.75 Could this be related to the behavior fixed by bug 23680? I've tested too, but couldn't reproduce the problem: Google Chrome Version 70.0.3538.77 (Official Build) (64-bit) in Ubuntu I think the print code was changed at some point - which version are you looking at? I tested on master. This is happening to me on master in Chrome 78.0.3904.97 Same results for me - go to print, window opens and immediately closes. I think this is because the setTimeout() is too quick for Chrome. (1ms) 967 [% IF print %] 968 window.print(); 969 setTimeout('window.close()', 1); 970 [% END %] Created attachment 95589 [details] [review] Bug 24061: change setTimeout in opac-shelves.tt TEST PLAN: -set up a new public list with a few items -go to the OPAC and view that list. -Click 'Print List' in Chrome. -The tab opens but immediately closes itself. -Apply patch and try again -Now you can print! Created attachment 95591 [details] [review] [ALTERNATIVE-PATCH] Bug 24061: Close the window after the page has been printed Hi Lucas, Stackoverflow suggests to close the window after it has been print, ie. it takes back the focus. The solution sounds quite good to me. Could you try it? Created attachment 95623 [details] [review] Bug 24061: Close the window after the page has been printed Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Jonathan, Yes this seems better to me and works perfect. Obsoleted my patch and SO'd on yours. Thanks so much. If you cancel the print action, the extra tab is not closed in Firefox. In that sense increasing the timeout worked better. (In reply to Marcel de Rooy from comment #12) > If you cancel the print action, the extra tab is not closed in Firefox. In > that sense increasing the timeout worked better. It works for me, could you retry? (In reply to Jonathan Druart from comment #13) > (In reply to Marcel de Rooy from comment #12) > > If you cancel the print action, the extra tab is not closed in Firefox. In > > that sense increasing the timeout worked better. > > It works for me, could you retry? Retried although nothing changed. And still does not close the additional tab in FF when canceling the print dialog. If I confirm printing, it does close. Which versions of Firefox are you using? (In reply to Jonathan Druart from comment #15) > Which versions of Firefox are you using? 70.0.1 (In reply to Marcel de Rooy from comment #16) > (In reply to Jonathan Druart from comment #15) > > Which versions of Firefox are you using? > > 70.0.1 I have exactly this version... Created attachment 95664 [details] [review] Bug 24061: Close the window after the page has been printed (In reply to Jonathan Druart from comment #17) > (In reply to Marcel de Rooy from comment #16) > > (In reply to Jonathan Druart from comment #15) > > > Which versions of Firefox are you using? > > > > 70.0.1 > > I have exactly this version... So, interestingly, or not, it did work on Firefox 70.0.1 but not on chromium. This patch makes the use of the onafterprint event which sounds definitely the correct way. This one works with chromium and Firefox. Not with Chrome... (In reply to Jonathan Druart from comment #20) > Not with Chrome... https://www.w3schools.com/tags/ev_onafterprint.asp It says from Chrome 63, so I think it's the way to go. Does not work fine with Chrome 62 too. Also a problem with Edge. Firefox seems to work. Easier to increase the timeout? Waiting for 1 second before closing the window? Looks very ugly to me. Created attachment 95715 [details] [review] Bug 24061: close after timeout if onafterprint no supported Not supported on Chrome < 63 https://www.w3schools.com/tags/ev_onafterprint.asp Let's do both then... (In reply to Jonathan Druart from comment #25) > Let's do both then... Seems to work in a quick test. Firefox, Chrome and Edge. Edge ask for permission to close the tab. Maybe change 1000 to 500 or even less? 100 works with me on Chrome printing a public list from the OPAC in chrome now works with this patch. The patch was tested on Chrome 79 and worked properly. Created attachment 96971 [details] [review] Bug 24061: close after timeout if onafterprint no supported Not supported on Chrome < 63 https://www.w3schools.com/tags/ev_onafterprint.asp Signed-off-by: Gabriel DeCarufel <gabriel@inlibro.com> Created attachment 97597 [details] [review] Bug 24061: Close the window after the page has been printed Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Created attachment 97598 [details] [review] Bug 24061: Close after timeout if onafterprint no supported Not supported on Chrome < 63 https://www.w3schools.com/tags/ev_onafterprint.asp Signed-off-by: Gabriel DeCarufel <gabriel@inlibro.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Reported in November... moving forward as this works ok for me in all tested browsers (Chrome, Chromium, Firefox). Nice work everyone! Pushed to master for 20.05 Pushed to 19.11.x branch for 19.11.03 backported to 19.05.x for 19.05.08 Backported to 18.11.x for 18.11.14. |