Skip to content

Fix text cutting off when printing and differences between clicking print and doing ctrl + P #10670

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

Merged
merged 1 commit into from
Mar 27, 2025

Conversation

GVodyanov
Copy link
Contributor

@GVodyanov GVodyanov commented Feb 9, 2025

Fix #9853

Previously for printing all we did was hide unnecessary DOM elements with CSS

What this PR actually does:

  • distinguish between printing singular messages (through the actions menu) and printing the whole thread with Ctrl + P
  • If printing a specific message only the iframe is printed, with thread info injected up top
  • If printing a whole thread with Ctrl + P some DOM elements are hidden with CSS, and some are removed forcefully with javascript. This is needed because browser printing APIs aren't the best, and even hidden elements mess up the layout with Chrome. The downside of this is that the browser cannot read elements inside of iframes, so text and images are split between multiple pages. After this is done the page has to be reloaded to restore the deleted elements.
  • Fix bug related to the print content being narrow in Firefox, this was caused by the actions menu still existing in the DOM even if hidden for a few seconds after being closed
  • Update iframe-resizer to version 5: now it split between two libraries, child and parent
  • Handle printing of plain text messages by creating an iframe and inserting them into it

@GVodyanov GVodyanov self-assigned this Feb 9, 2025
@GVodyanov
Copy link
Contributor Author

Note: narrow messages in firefox seem to reproducible only after having clicked the menu buttons in the thread element, even though the menu was subsequently closed..?

@GVodyanov GVodyanov force-pushed the fix/text-cutting-off-print branch from 0d018da to 4981e8f Compare March 6, 2025 19:31
@GVodyanov GVodyanov marked this pull request as ready for review March 6, 2025 19:38
@ChristophWurst
Copy link
Member

After this is done the page has to be reloaded to restore the deleted elements.

This feels a bit bumpy, but I also lack alternative ideas off the top of my head …

@GVodyanov
Copy link
Contributor Author

After this is done the page has to be reloaded to restore the deleted elements.

This feels a bit bumpy, but I also lack alternative ideas off the top of my head …

I tried reinserting the deleted elements back afterwards, but I can't figure out how to insert them back into the right place, they kept getting appended to the end of the component.

Copy link
Contributor

@SebastianKrupinski SebastianKrupinski left a comment

Choose a reason for hiding this comment

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

Tested. Single mails and threads, works good.

@GVodyanov GVodyanov force-pushed the fix/text-cutting-off-print branch from f1acc9f to ac0318a Compare March 27, 2025 14:59
@GVodyanov GVodyanov force-pushed the fix/text-cutting-off-print branch from ac0318a to e373f05 Compare March 27, 2025 15:10
@GVodyanov GVodyanov merged commit 3b22ed5 into main Mar 27, 2025
35 checks passed
@GVodyanov GVodyanov deleted the fix/text-cutting-off-print branch March 27, 2025 15:22
@GVodyanov
Copy link
Contributor Author

/backport to stable4.3

Copy link

backportbot bot commented Apr 3, 2025

The backport to stable4.3 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable4.3
git pull origin stable4.3

# Create the new backport branch
git checkout -b backport/10670/stable4.3

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick e373f05a

# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/10670/stable4.3

Error: Failed to cherry pick commits: error: no cherry-pick or revert in progress
fatal: cherry-pick failed


Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

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.

Printing edge case emails still does not always work
3 participants