lib/karafka/web/ui/public/javascripts/components/theme_manager.js in karafka-web-0.10.0.beta1 vs lib/karafka/web/ui/public/javascripts/components/theme_manager.js in karafka-web-0.10.0.rc1

- old
+ new

@@ -5,22 +5,29 @@ this.themeSelectorDark = document.getElementById('theme-selector-dark'); this.init(); } init() { - this.lightThemeLink = document.getElementById('highlight-light'); - this.darkThemeLink = document.getElementById('highlight-dark'); + this.lightThemeLink = document.querySelector('.highlight-light'); + this.darkThemeLink = document.querySelector('.highlight-dark'); if (!this.lightThemeLink || !this.darkThemeLink || !this.themeSelectorButton) { console.error('Theme CSS links or theme selector button not found'); return; } this.restoreTheme(); - this.themeSelectorButton.addEventListener('click', () => { - this.toggleTheme(); - }); + this.bindThemeSelectorButton(); + } + + bindThemeSelectorButton() { + if (this.themeSelectorButton && !this.themeSelectorButton.dataset.bound) { + this.themeSelectorButton.addEventListener('click', () => { + this.toggleTheme(); + }); + this.themeSelectorButton.dataset.bound = 'true'; // Mark the button as bound + } } setTheme(theme) { document.documentElement.setAttribute('data-theme', theme); if (theme === 'dark') {