From 9f8e5a6d1c0a62490783f9a1334a56335ffcabf1 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 28 May 2026 14:33:59 +0800 Subject: [PATCH] fix: retry theme icon update until bricks button element exists --- wwwroot/shell_theme.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wwwroot/shell_theme.js b/wwwroot/shell_theme.js index 625ee6f..2b86ddb 100644 --- a/wwwroot/shell_theme.js +++ b/wwwroot/shell_theme.js @@ -122,6 +122,18 @@ initRouter(); } + // Bricks widgets render asynchronously after DOMContentLoaded. + // Retry updateThemeIcon until the button element exists. + (function retryThemeIcon() { + var btn = document.getElementById('theme_toggle_btn'); + if (btn) { + var theme = document.documentElement.getAttribute('data-theme') || 'dark'; + updateThemeIcon(theme); + } else { + setTimeout(retryThemeIcon, 200); + } + })(); + // Expose global functions for bricks bind access window.sageToggleTheme = toggleTheme; window.sageToggleSidebar = toggleSidebar;