FIX: make full height menu and cloak respect custom headers (#6845)

FIX: make full height menu and cloak respect custom headers (#6845)

diff --git a/app/assets/javascripts/discourse/components/site-header.js.es6 b/app/assets/javascripts/discourse/components/site-header.js.es6
index ab765a0..a0dd8a2 100644
--- a/app/assets/javascripts/discourse/components/site-header.js.es6
+++ b/app/assets/javascripts/discourse/components/site-header.js.es6
@@ -367,7 +367,7 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
           $headerCloak.show();
         }
 
-        const menuTop = this.site.mobileView ? 0 : headerHeight();
+        const menuTop = this.site.mobileView ? headerTop() : headerHeight();
 
         let height;
         const winHeightOffset = 16;
@@ -386,6 +386,7 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
         }
         if (style.top !== menuTop + "px" || style.height !== height) {
           $panel.css({ top: menuTop + "px", height });
+          $(".header-cloak").css({ top: menuTop + "px" });
         }
         $("body").removeClass("drop-down-mode");
       }
@@ -434,3 +435,10 @@ export function headerHeight() {
     $header.outerHeight() + headerOffsetTop - $(window).scrollTop()
   );
 }
+
+export function headerTop() {
+  const $header = $("header.d-header");
+  const headerOffset = $header.offset();
+  const headerOffsetTop = headerOffset ? headerOffset.top : 0;
+  return parseInt(headerOffsetTop - $(window).scrollTop());
+}

GitHub
sha: 49fbedc4

1 Like

Same changes as before, but calculations take scroll position into account correctly now.

1 Like