8000 Don't display the Symfony debug toolbar when printing the page by javiereguiluz · Pull Request #23460 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Don't display the Symfony debug toolbar when printing the page #23460

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

Closed
wants to merge 3 commits into from

Conversation

javiereguiluz
Copy link
Member
Q A
Branch? 2.8
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #23303
License MIT
Doc PR -

@media print {
.sf-toolbar, .sf-error-toolbar {
display: none;
visibility: hidden;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason for this if there is already display: none?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was in the original CSS rule ... but you are right and this is no longer needed (Bootstrap v4 doesn't use that either. See https://github.com/twbs/bootstrap/blob/v4-dev/scss/_print.scss)

@xabbuh xabbuh added this to the 2.8 milestone Jul 10, 2017
@stof
Copy link
Member
stof commented Jul 10, 2017

Actually, the issue is that the media query hiding the whole toolbar (error one or normal one) is missing now.
the 2.7 branch has this code before the error toolbar:

/***** Media query print: Do not print the Toolbar. *****/
@media print {
    .sf-toolbar {
        display: none;
        visibility: hidden;
    }
}

But the 2.8 branch does not seem to have it anymore.

I suspect a bad conflict resolution when merging branches


/***** Media query print: Do not print the Toolbar. *****/
@media print {
.sf-toolbar, .sf-error-toolbar {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.sf-error-toolbar is useless here, as the error toolbar also has the sf-toolbar class

@nicolas-grekas
Copy link
Member

Thank you @javiereguiluz.

This was referenced Jul 17, 2017
fabpot added a commit that referenced this pull request Oct 16, 2020
This PR was merged into the 3.4 branch.

Discussion
----------

[WebProfilerBundle] Hide debug toolbar in print view

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| License       | MIT

The debug toolbar is intended to be hidden when printed. This was accomplished in 2.8 with [this PR](#23460). Since then, additional JavaScript code was added which results in `display: block` being applied directly to the toolbar element. This overrides the print style, which causes the toolbar to show up in the print view. I fixed this by adding `!important` to the print CSS display rule.

A few notes:

1. I hesitated to solve this with `!important` but couldn't come up with another way to make this work with the existing JavaScript code. Also, `profiler.css.twig` already has some `!important` styles, so I figured this was acceptable.
2. I wasn't sure how to write a test for this, but I am open to ideas.

Commits
-------

fb30516 [WebProfilerBundle] Hide debug toolbar in print view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0