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.

Comments

stupiddingo’s picture

Status: Active » Needs review
StatusFileSize
new349 bytes

Patch attached.

mgifford’s picture

Issue tags: +print.css
gisle’s picture

Status: Needs review » Reviewed & tested by the community

Patch 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.

pol’s picture

Issue tags: +Drupal 7.60 target

Looks fine for me.

pol’s picture

Issue tags: +Pending Drupal 7 commit
joseph.olstad’s picture

Issue tags: -Drupal 7.60 target +Drupal 7.61 target

Bumping to 7.61, this didn't make it into 7.60

joseph.olstad’s picture

joseph.olstad’s picture

mcdruid’s picture

Issue tags: -Drupal 7.64 target +Drupal 7.68 target, +Already In D8

A 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.

stefanos.petrakis’s picture

Status: Reviewed & tested by the community » Needs work

(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.asp as 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.

joseph.olstad’s picture

Status: Needs work » Reviewed & tested by the community

IE8 is a security risk and has virtually zero usage in 2019

Effective January 12, 2016, Internet Explorer 8 is no longer supported on any client or server version of Windows

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.

joseph.olstad’s picture

Status: Reviewed & tested by the community » Active

ah ok, I'm not against the change proposted by Stefanos if it means maintaining status quo.

joseph.olstad’s picture

Status: Active » Needs review

Stefanos, 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?

stefanos.petrakis’s picture

Here is a patch that doesn't utilize media queries and produces the following HTML:

<style type="text/css" media="print">
@import url("http://d7.site/modules/toolbar/toolbar-print.css?q0grxl");
</style>

@joseph.olstad: I think that the media attribute approach is legit and does solve the issue while keeping IE8 and earlier in the picture.

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

Looks good thanks @Stefanos!

mcdruid’s picture

Thanks @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.

mcdruid’s picture

Issue tags: +Drupal 7 bugfix target
fabianx’s picture

Assigned: Unassigned » mcdruid

RTBM - Let’s get that in.

  • mcdruid committed 88de173 on 7.x
    Issue #2472025 by stupiddingo, stefanos.petrakis: [D7] Hide toolbar when...
mcdruid’s picture

Title: Hide toolbar when printing (7.x) » [D7] Hide toolbar when printing
Assigned: mcdruid » Unassigned
Status: Reviewed & tested by the community » Fixed
Issue tags: -Pending Drupal 7 commit, -Drupal 7 bugfix target
Parent issue: » #2403639: Remove toolbar from print view
Related issues: -#2403639: Remove toolbar from print view

Thank you contributors!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.