The toolbar isn't hidden when printing on most themes.
Attached is print view taken using stark theme. The same behavior was found in garland, seven and bootstrap. Some themes like bartik and omega include specific rules to hide the toolbar.
This is similar to the 8.x Issue https://www.drupal.org/node/2403639 however the css for 7.x is less complex and the fix requires only a single stylesheet rule. This didn't feel quite like a patch reroll, but I correct me if I am mistaken and I will post there instead.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | drupal-hide_toolbar_when_printing-2472025-14.patch | 765 bytes | stefanos.petrakis |
| toolbar-visible-printing-stark-theme.png | 125.08 KB | stupiddingo |
Comments
Comment #1
stupiddingo commentedPatch attached.
Comment #2
mgiffordComment #3
gislePatch works great!
Having the toolbar clobber the printout when you are printing out field lists and similar when debugging is a PITA.
This is already fixed in Drupal 8, but we need it in Drupal 7 as well.
Comment #4
polLooks fine for me.
Comment #5
polComment #6
joseph.olstadBumping to 7.61, this didn't make it into 7.60
Comment #7
joseph.olstadComment #8
joseph.olstadComment #9
mcdruid commentedA quick review (noting I am not a CSS expert).
There are hardly any media queries in D7 core's CSS; I can only see a handful in the simpletest module. They're very well supported across all modern browsers though.
However, it doesn't look like it would work to add these rules to an existing print.css file, and I'd imagine adding a print.css file to the toolbar module would be unnecessarily complicated. Adding the rules to the toolbar module definitely makes sense.
The patch looks very similar to the one committed to D8 in #2403639: Remove toolbar from print view.
So this looks to me like a low-risk, pragmatic fix which is worth doing.
Comment #10
stefanos.petrakis(not a css specialist by any account either) :-)
I would like to point out that this solution is not supported by IE8 (and earlier). (
https://www.w3schools.com/cssref/css3_pr_mediaquery.aspas reported in the link previously posted by mcdruid)Which may still be important to support and is listed as a supported browser by D7 in the documentation
(https://www.drupal.org/docs/7/system-requirements/browser-requirements ).
I am not really aware of the current strategic approach to this however.
An alternative that would support IE8 would be adding this inside a print.css file (the complicated option), that would produce the following HTML:
<link rel="stylesheet" type="text/css" href="print.css" media="print">Thoughts? Will set this back to "Needs work" for now.
Comment #11
joseph.olstadIE8 is a security risk and has virtually zero usage in 2019
jQuery UI version 12.1 removed support for IE8 in 2016
https://jqueryui.com/changelog/1.12.0/
Please update the supported browsers page silently and remove any mention of IE8.
Comment #12
joseph.olstadah ok, I'm not against the change proposted by Stefanos if it means maintaining status quo.
Comment #13
joseph.olstadStefanos, do you really think IE8 is worth any effort at all other than the effort to quietly remove the mention of it in the supported browsers page?
Comment #14
stefanos.petrakisHere is a patch that doesn't utilize media queries and produces the following HTML:
@joseph.olstad: I think that the media attribute approach is legit and does solve the issue while keeping IE8 and earlier in the picture.
Comment #15
joseph.olstadLooks good thanks @Stefanos!
Comment #16
mcdruid commentedThanks @stefanos.petrakis, I think it's better to do it this way rather than introduce media queries where there are currently (almost) none in D7 core.
@Fabianx knows the render system well, so it'll be good to get his review, but this LGTM.
Comment #17
mcdruid commentedComment #18
fabianx commentedRTBM - Let’s get that in.
Comment #20
mcdruid commentedThank you contributors!