From 301d5657fe3643ddf0ef5a3833933de54a5fa392 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Wed, 8 Dec 2021 01:40:49 +0100 Subject: [PATCH] FIX: --header-offset didn't account for overscroll (#15221) Fixes miniprofiler badge sliding away from the header when you rubber-band overscroll on the top of the page (in Safari) --- .../discourse/app/components/site-header.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/site-header.js b/app/assets/javascripts/discourse/app/components/site-header.js index 32045dec662..2be7047b78d 100644 --- a/app/assets/javascripts/discourse/app/components/site-header.js +++ b/app/assets/javascripts/discourse/app/components/site-header.js @@ -183,9 +183,13 @@ const SiteHeaderComponent = MountWidget.extend( } const offset = info.offset(); - const headerRect = header.getBoundingClientRect(), - headerOffset = headerRect.top + headerRect.height, - doc = document.documentElement; + const headerRect = header.getBoundingClientRect(); + const doc = document.documentElement; + let headerOffset = headerRect.top + headerRect.height; + + if (window.scrollY < 0) { + headerOffset -= window.scrollY; + } const newValue = `${headerOffset}px`; if (newValue !== this.currentHeaderOffsetValue) {