A platform for community discussion. Free, open, simple.
DEV: Delay rendering sidebar sections after sidebar is shown (#27227)
Natalie Tay7aa5c648064c
diff --git a/app/assets/javascripts/discourse/app/components/deferred-render.gjs b/app/assets/javascripts/discourse/app/components/deferred-render.gjsnew file mode 100644index 00000000000..aec52fd5c72--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/deferred-render.gjs@@ -0,0 +1,18 @@+import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";+import runAfterFramePaint from "discourse/lib/after-frame-paint";++export default class DeferredRender extends Component {+ @tracked shouldRender = false;++ constructor() {+ super(...arguments);+ runAfterFramePaint(() => (this.shouldRender = true));+ }++ <template>+ {{#if this.shouldRender}}+ {{yield}}+ {{/if}}+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.gjs b/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.gjsindex 17aa3feac85..249fa24dfbd 100644--- a/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.gjs+++ b/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.gjs@@ -3,6 +3,7 @@ import { action } from "@ember/object";import didInsert from "@ember/render-modifiers/modifiers/did-insert";import { service } from "@ember/service";import { or } from "truth-helpers";+import DeferredRender from "discourse/components/deferred-render";import ApiPanels from "./api-panels";import Footer from "./footer";import Sections from "./sections";@@ -39,25 +40,26 @@ export default class SidebarHamburgerDropdown extends Component {><div class="panel-body"><div class="panel-body-contents">- <div class="sidebar-hamburger-dropdown">- {{#if- (or this.sidebarState.showMainPanel @forceMainSidebarPanel)- }}- <Sections- @currentUser={{this.currentUser}}- @collapsableSections={{this.collapsableSections}}- @panel={{this.sidebarState.currentPanel}}- @hideApiSections={{@forceMainSidebarPanel}}- />- {{else}}- <ApiPanels- @currentUser={{this.currentUser}}- @collapsableSections={{this.collapsableSections}}- />- {{/if}}-- <Footer />- </div>+ <DeferredRender>+ <div class="sidebar-hamburger-dropdown">+ {{#if+ (or this.sidebarState.showMainPanel @forceMainSidebarPanel)+ }}+ <Sections+ @currentUser={{this.currentUser}}+ @collapsableSections={{this.collapsableSections}}+ @panel={{this.sidebarState.currentPanel}}+ @hideApiSections={{@forceMainSidebarPanel}}+ />+ {{else}}+ <ApiPanels+ @currentUser={{this.currentUser}}+ @collapsableSections={{this.collapsableSections}}+ />+ {{/if}}+ <Footer />+ </div>+ </DeferredRender></div></div></div>