Skip to content
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

Link stylesheet with media attribute value tip #637

Closed
sbecka opened this issue Aug 28, 2023 · 1 comment · Fixed by #645
Closed

Link stylesheet with media attribute value tip #637

sbecka opened this issue Aug 28, 2023 · 1 comment · Fixed by #645

Comments

@sbecka
Copy link

sbecka commented Aug 28, 2023

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.

@MatthewHerbst
Copy link
Owner

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! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants