From 4ca6717994811eb334c79e4ec14a07b22e064a9f Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Mon, 22 Aug 2022 19:08:24 +0200 Subject: [PATCH] DEV: Use `.ember-application` instead of `#main` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `#main` in the test environment is replaced with `#ember-testing`, so this code would break. It never did only because we don't test these code paths 👀 --- .../javascripts/discourse/app/components/site-header.js | 2 +- app/assets/javascripts/discourse/app/mixins/scrolling.js | 4 +++- .../javascripts/discourse/app/widgets/topic-admin-menu.js | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/site-header.js b/app/assets/javascripts/discourse/app/components/site-header.js index 2b4e2541be5..2331149c995 100644 --- a/app/assets/javascripts/discourse/app/components/site-header.js +++ b/app/assets/javascripts/discourse/app/components/site-header.js @@ -177,7 +177,7 @@ const SiteHeaderComponent = MountWidget.extend( this.docAt = header.offsetTop; } - const main = document.querySelector("#main"); + const main = document.querySelector(".ember-application"); const offsetTop = main ? main.offsetTop : 0; const offset = window.pageYOffset - offsetTop; if (offset >= this.docAt) { diff --git a/app/assets/javascripts/discourse/app/mixins/scrolling.js b/app/assets/javascripts/discourse/app/mixins/scrolling.js index ced98a406f9..7dd83644abb 100644 --- a/app/assets/javascripts/discourse/app/mixins/scrolling.js +++ b/app/assets/javascripts/discourse/app/mixins/scrolling.js @@ -19,7 +19,9 @@ const ScrollingDOMMethods = { }, screenNotFull() { - return window.height > document.querySelector("#main").offsetHeight; + return ( + window.height > document.querySelector(".ember-application").offsetHeight + ); }, }; diff --git a/app/assets/javascripts/discourse/app/widgets/topic-admin-menu.js b/app/assets/javascripts/discourse/app/widgets/topic-admin-menu.js index 1ca2054c78a..d019fe8046d 100644 --- a/app/assets/javascripts/discourse/app/widgets/topic-admin-menu.js +++ b/app/assets/javascripts/discourse/app/widgets/topic-admin-menu.js @@ -334,8 +334,9 @@ export default createWidget("topic-admin-menu", { if (attrs.openUpwards) { const documentHeight = $(document).height(); - const mainHeight = $("#main").height(); - let bottom = documentHeight - top - 70 - $("#main").offset().top; + const mainHeight = $(".ember-application").height(); + let bottom = + documentHeight - top - 70 - $(".ember-application").offset().top; if (documentHeight > mainHeight) { bottom = bottom - (documentHeight - mainHeight) - outerHeight;