Header submenus theme component pushes bottom of sidebar out of the screen

Custom headers aren’t included in the calculation at all, this can be repro’d by adding any content to the header section of a theme.

The calculation we use for the sidebar and chat takes into consideration the height of the Discourse header and sets --header-offset as a variable when calculating some heights.

Including custom headers might be a little tricky because custom header content doesn’t stick on scroll by default like the Discourse header does… so if we include it in the calculation by default, once you scroll and the custom header is gone, the height is then incorrect.

So for example, if I manually increase --header-offset by the height of my custom header (it’s roughly 60px by default), you get a gap above the sidebar on scroll:

We add a .docked class to the body once a custom header is scrolled out of view, so it’s possible to use this… which is better, but there’s a noticable transition as the sidebar height adjusts between states… this is becuase .docked is either on or off.

If you want a sticky header, this is a little easier to work around… because you can increase --header-offset by the height of the custom header, and then set .d-header-wrap’s top value as the height of the custom header:

One solution that comes to mind for improving the case of the non-sticky header is to:

  1. Check the height of the custom header
  2. Include the custom header height in --header-offset
  3. De-increment the custom header height used in the --header-offset calculation based on scroll position. This will more gradually adjust the sidebar height in a way that the .docked class can not.

Might take some experimentation to get it right…

5 Likes