A platform for community discussion. Free, open, simple.
UX: Ensure sticky elements don't overflow header (#14432)
Penar Musaraj8a250a1eac90
diff --git a/app/assets/javascripts/discourse/app/components/site-header.js b/app/assets/javascripts/discourse/app/components/site-header.jsindex d78e9c7d49b..3d655738774 100644--- a/app/assets/javascripts/discourse/app/components/site-header.js+++ b/app/assets/javascripts/discourse/app/components/site-header.js@@ -183,16 +183,21 @@ const SiteHeaderComponent = MountWidget.extend(}const offset = info.offset();+ const headerRect = header.getBoundingClientRect(),+ headerOffset = headerRect.top + headerRect.height,+ doc = document.documentElement;if (offset >= this.docAt) {if (!this.dockedHeader) {document.body.classList.add("docked");this.dockedHeader = true;+ doc.style.setProperty("--header-offset", `${headerOffset}px`);}} else {if (this.dockedHeader) {document.body.classList.remove("docked");this.dockedHeader = false;}+ doc.style.setProperty("--header-offset", `${headerOffset}px`);}},diff --git a/app/assets/stylesheets/common/base/_topic-list.scss b/app/assets/stylesheets/common/base/_topic-list.scssindex 6cf2ac186ef..a9297bd0862 100644--- a/app/assets/stylesheets/common/base/_topic-list.scss+++ b/app/assets/stylesheets/common/base/_topic-list.scss@@ -171,8 +171,7 @@.sticky-header thead {@include sticky;- // TODO: Use calculated header height- top: 60px;+ top: var(--header-offset, 60px);background: var(--secondary);z-index: 2;}diff --git a/app/assets/stylesheets/common/base/compose.scss b/app/assets/stylesheets/common/base/compose.scssindex 4a7fbfe9060..78d2d938d8a 100644--- a/app/assets/stylesheets/common/base/compose.scss+++ b/app/assets/stylesheets/common/base/compose.scss@@ -517,6 +517,7 @@ body:not(.ios-safari-composer-hacks) {#reply-control.open {--min-height: 255px;min-height: var(--min-height);+ max-height: calc(100vh - var(--header-offset, 4em));&.composer-action-reply {// we can let the reply composer get a little shortermin-height: calc(var(--min-height) - 4em);diff --git a/app/assets/stylesheets/common/base/topic.scss b/app/assets/stylesheets/common/base/topic.scssindex 0a5bdc56ab7..568b3475837 100644--- a/app/assets/stylesheets/common/base/topic.scss+++ b/app/assets/stylesheets/common/base/topic.scss@@ -46,7 +46,7 @@grid-area: timeline;align-self: start;@include sticky;- top: 6em;+ top: calc(var(--header-offset, 60px) + 2em);margin-left: 1em;z-index: z("timeline");}