In the end, it was due to a component higher up in the web page's structure with the style height: 100vh;
. For a normal page, this worked; the page was globally not scrollable, and my sidebar's div was made scrollable, as well as the main content div, which could be scrolled within as well.
However, for printing, it is important that height of content is not limited or set in a hardcoded pixels value.
TLDR: Make sure the container's height is set to height: auto;
with @media print { ... }