Wiki "Print as PDF" contains unwanted HTML elements

Summary

When using "Print as PDF" inside a GitLab Wiki, it adds different HTML elements from the page, that either block or are not wanted.

Steps to reproduce

I have tested this inside of Firefox 145.0 on Linux and on GitLab.com inside a simple test project.

  1. Create a Wiki page (I have tested it with small and large amounts of content)
  2. Ensure that the sidebar with the Wiki pages is open
  3. Select "Print as PDF" (or press Ctrl+P)

Example Project

I currently do not have a public GitLab repository with a Wiki so I have searched for a GitLab Repository with a Wiki:

If Ctrl+P is pressed, the same is happening in here: The KiCAD wiki home page

What is the current bug behavior?

When the user clicks on "Export to PDF" inside a Wiki article, it will contain the sidebar (if it is not closed) on the second page and all pages after that page. Sometimes it even creates a second page for that. But this was inconsistent.

Also when the user creates a page and directly after that uses that "Export to PDF" button the toast that the page was created, is also there.

What is the expected correct behavior?

Relevant logs and/or screenshots

Screenshot of a small Wiki page printed to a PDF

Screenshot of a large Wiki page printed to a PDF

Output of checks

This bug happens on GitLab.com

Possible fixes

This could be fixed by adding a display: none; to these elements when in printing mode.

@media print {
   .media-sidebar {
      display: none;
   }
}

but as I do not know the specifics, this is just some idea.

Edited by 🤖 GitLab Bot 🤖