-
Notifications
You must be signed in to change notification settings - Fork 315
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
Print directly from Edit/Share/New pages #3491
Conversation
That doesn't make any sense, @media print is very clear at what it does |
Exactly. It doesnt make any sense. And yet, if you try it, you will see that removing that line of CSS prevents the issue. |
I don't seem to be able to reproduce the issue, either on the deployment or in my local build. Can you share a link to the test doc on the deployment for further experimentation please? |
It's just a blank document with 7 pages.
Scroll to the bottom. Print. Close print dialog. Scroll to the top. The top 2 pages are invisible. |
Doesn't happen for me, in chrome or firefox. Tested with just the blank pages and with additional stuff, in the deployment. I can try checking out to local if necessary |
Hmmmm. Well if it's just me.... Let me just try clearing my cache and everything. Maybe Chrome is just acting up. I will try to record a video as well if it's still there. |
I tested the issue again just now with a clean install of Chrome on two different machines. It occurs for me in local and in the deployment, on both Chrome and Edge, but not Firefox. Occurs on all of /new, /share, and /edit. Test brew: https://homebrewery-pr-3491.herokuapp.com/share/2qpSNU5IzHjO Recording.2024-05-23.001905.mp4 |
WTF It didn't happen |
I think I have a solution for this. |
...and now it's not doing it any more. This makes diagnostics considerably more difficult. EDIT: Okay, I seem to have a reasonably reliable issue reproduction method.
Pressing CTRL+P from the Editor does NOT exhibit the same behaviour. I went through and added content to each page (literally, only the page number: 1, \page, 2, \page, etc.) Using this reproduction method, I can see that while the third page is present, it has no content, while pages 1 and 2 are not rendered at all. |
Okay, who made a pact with a fey? who was it? |
Ok, so.... after lots of fiddling, I think I have a workaround, but it's dumb. It appears that triggering the print dialog forces a reflow of the brewRenderer, and somehow it is using the If I add these lines to the printing step, it basically forces a repaint of the DOM, which works, but is really dumb.
|
How can you know that? and are we sure about it? There might be an alternative to the @media print what if we apply css right before printing via js and then remove it later? |
I mean, at some point its just a best guess based on what I've seen. We know for sure is that it is specifically the We also know that opening the print dialog triggers a repaint of the brewrenderer in the background. In the video below, I have Chrome set to flash green any component that gets repainted. You can see the brewRenderer element flashes green behind the print dialog when it first opens, but it does not flash green when the dialog closes. So we can also guess that the pages are disappearing when the print dialog first opens. Recording.2024-05-23.150949.mp4Here my new code that adds a repaint added after the print dialog closes. You can see another green flash when I close the dialog: Recording.2024-05-23.163200.mp4 |
I tried this as well. This does mostly the same thing as my solution, since since removing the CSS causes a repaint when the dialog closes. But unfortunately it adds two downsides:
|
Ok, I think the two major issues are fixed. Missing pages are handled and CTRL-P is now captured in the iframe. |
Confirmed; my reproduction method no longer produces the issue. |
Using this PR, users can now print all pages, we might want to block printing in account page. Changelog, Home page, user page, they are all printable. |
Shouldn't this PR delete the print page altogether apart from adding this function? |
Look up at the original post. It's already one of the open tasks. |
Default browser printing still works
I just made a tweak so hotkey printing when focused on the brewRenderer iFrame only generates the full PDF on Share/Edit/New. The other pages now just fall back to the default Chrome print action, unchanged from their current behavior on the live site. I don't think we need to entirely block all forms of printing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, what is left?
Maybe changing the names for some methods? printPage to printFunction?
Avoid confusion with other "page" components.
Changed the function to |
Implements #2742
Supersedes #3464 , as it solves the same issue and removes the need for
/print
endpoint entirely.Appears to work fine with legacy/V3, cross-page variables, etc. All functional features in the brewRenderer are printed correctly.
Open Tasks:
overflow-y: unset;
line in the@media print
CSS somehow?/print
page and associated routing code.