-
-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safari 11 print issues #137
Comments
I can confirm this as well (Safari 11.0.1). I also found another issue in a similar jQuery plugin for printing (DoersGuild/jQuery.print#78), this is probably triggered by the same root cause. Printing seems to work fine the first time page is loaded, but when trying to print more than one time without reloading the page in between, Safari shows the following dialog: ...and no matter what the user select, nothing else appears and nothing is printed. I believe this is basically a bug in Safari. |
You only receive this notification if you cancel the print. If you actually print or use the Save as PDF features, you continue to get the print dialog. Once you cancel print, Safari asks the next time. The failure to print or print the complete content is due to the printThis iframe being removed by a timeout set before the alert, which stops execution but does't change the JavaScript timers. If you add This is presumably protection against pages popping up multiple print requests. We may be able to detect this condition and avoid removing the print iframe, but I do not have a clear mechanism to pursue at this time. |
Can anyone think of any reasons why using Adding this option fixed the issue in Safari, and I don't see much reason why I couldn't just roll with this on a production site until this issue gets patched? Wondering why this option fixes Safari? What part of the code base related to Thanks so much for this useful tool! |
Ah, I see that debug adds visible iframes to the body. This seems to fix it: /* https://github.com/jasonday/printThis/issues/137 */
body > iframe[name="printIframe"] {
position: absolute;
top: -999em;
left: -999em;
} Also, maybe we could use JS to remove the iframe after printing ... Going to use CSS option above for now. |
@mhulse I think your particular issue is separate from OP's. One thing you could try is to increase the printDelay option. My guess is that in your scenario, the print iframe needs more time to build. Additionally, we do remove the iframe programattically after print - https://github.com/jasonday/printThis/blob/master/printThis.js#L257 |
Ahhh, interesting! That's a great idea, thanks! I'll give it a try. I really appreciate the help and thanks so much for this awesome plugin! Printing is such a pain in the @rse... Nice to have a tool like this that requires minimal effort to make things look good. |
Maybe we can utilize matchMedia on Safari to detect when to remove an element:
Needs a bit more testing though. |
@jasonday Has there been any progress on this issue? I'm currently using printThis in an Ember addon and having the exact same issue as the OP. As has been noted, this seems to be an issue with Safari. Is there a known workaround or has this issue fallen through the cracks? |
I was able to reproduce it the other day with a recent version of Safari, so it still seems to be present. As previously said it only happens when first canceling a print and then trying to print again, so it appeared a lot for us during development, but we haven't had any customers reporting it in production. |
Safari 11 seems to have issues around some part of the implementation of printThis. Sometimes it'll prompt the user to ensure if you want to print or not, and after hitting yes it has inconsistent results. It'll either work fine, print a blank page, never display the print dialog, or even crash. It kind of feels like a bug in safari but maybe it can be worked around.
====================================================================
I use printThis in an ember addon. There's a demo below that reproduces the issue but if desired I can make a vanilla print this demo to show it off.
https://lucashill.github.io/ember-print-this/
====================================================================
Steps to reproduce the problem
====================================================================
What is the expected behaviour?
... print dialog displays with content
====================================================================
What is the observed behaviour?
... inconsistent as described above
====================================================================
When you set
debug:true
and inspect the iframe, what do you see?... I can try this later sorry.
====================================================================
More Details
The text was updated successfully, but these errors were encountered: