From 96b981cabab4835799593c8ed6e2a86b6d98c35f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Mar 2026 12:13:41 +0000 Subject: [PATCH] perf: defer autoUpdate until menu is open to fix slow profile icon rendering autoUpdate from @floating-ui/dom was being started in connect(), causing immediate layout/size calculations for every menu instance on page load even while closed. Moved autoUpdate to only run when the menu is open, and stop when closed/toggled off. https://claude.ai/code/session_01FkTsyLvEod4qN6T5dNidkL --- app/components/DS/menu_controller.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/components/DS/menu_controller.js b/app/components/DS/menu_controller.js index 5e24b3a0f..9415a6748 100644 --- a/app/components/DS/menu_controller.js +++ b/app/components/DS/menu_controller.js @@ -24,7 +24,6 @@ export default class extends Controller { this.show = this.showValue; this.boundUpdate = this.update.bind(this); this.addEventListeners(); - this.startAutoUpdate(); } disconnect() { @@ -66,14 +65,18 @@ export default class extends Controller { this.show = !this.show; this.contentTarget.classList.toggle("hidden", !this.show); if (this.show) { + this.startAutoUpdate(); this.update(); this.focusFirstElement(); + } else { + this.stopAutoUpdate(); } }; close() { this.show = false; this.contentTarget.classList.add("hidden"); + this.stopAutoUpdate(); } focusFirstElement() {