You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, we really like this library and just wanted to share a tip we found with linking stylesheets and the media attribute. Thank you to everyone working on react-to-print and making it amazing!
The project I work on uses React, Ruby on Rails, and Chrome as our main browser and has been updating versions frequently over the past few months. We aren't sure when it happened exactly, but all the printing styles from our link elements were not displaying properly in Chrome's print preview. We thought is might have been a Content Security Policy issue because we added it recently and had trouble configuring everything or an issue with react-to-print. However, it appears that the media attribute was being automatically set to "screen" for our link elements like this: <link href="/example.css" rel="stylesheet" media="screen" />. Apparently the Rails version we now have (6.1.7) sets any blank media attribute stylesheet link to "screen". After we added media="all", all of our printing styles were finally displaying again.
The text was updated successfully, but these errors were encountered:
Hey there, this is great to know, thank you! I'm not sure how many others have a similar setup, but the advice can be generic enough - make sure your link elements have the right media property set, that it probably makes sense to be on the "Helpful Style Tips" section of the README. I'm happy to add this, though if you'd like to make a PR to do so, we love having new contributors! 😄
Hi, we really like this library and just wanted to share a tip we found with linking stylesheets and the media attribute. Thank you to everyone working on react-to-print and making it amazing!
The project I work on uses React, Ruby on Rails, and Chrome as our main browser and has been updating versions frequently over the past few months. We aren't sure when it happened exactly, but all the printing styles from our link elements were not displaying properly in Chrome's print preview. We thought is might have been a Content Security Policy issue because we added it recently and had trouble configuring everything or an issue with react-to-print. However, it appears that the media attribute was being automatically set to "screen" for our link elements like this:
<link href="/example.css" rel="stylesheet" media="screen" />
. Apparently the Rails version we now have (6.1.7) sets any blank media attribute stylesheet link to "screen". After we added media="all", all of our printing styles were finally displaying again.The text was updated successfully, but these errors were encountered: