From 3ee216c036e641a943aa8a1e9d280be9e421e3ba Mon Sep 17 00:00:00 2001 From: Kris Date: Wed, 4 Nov 2020 21:14:17 -0500 Subject: [PATCH] FIX: include header offset relative to window (#11114) --- .../javascripts/discourse/app/lib/offset-calculator.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/lib/offset-calculator.js b/app/assets/javascripts/discourse/app/lib/offset-calculator.js index c9cffee5cfd..9ce8c234e24 100644 --- a/app/assets/javascripts/discourse/app/lib/offset-calculator.js +++ b/app/assets/javascripts/discourse/app/lib/offset-calculator.js @@ -7,7 +7,14 @@ export function minimumOffset() { iPadNav = document.querySelector(".footer-nav-ipad .footer-nav"), iPadNavHeight = iPadNav ? iPadNav.offsetHeight : 0; - return header ? header.offsetHeight + iPadNavHeight : 0; + // if the header has a positive offset from the top of the window, we need to include the offset + // this covers cases where a site has a custom header above d-header (covers fixed and unfixed) + const headerWrap = document.querySelector(".d-header-wrap"), + headerWrapOffset = headerWrap.getBoundingClientRect(); + + return header + ? header.offsetHeight + headerWrapOffset.top + iPadNavHeight + : 0; } export default function offsetCalculator() {