From 4512a5b75ade1dbdc0a804f0aa3e82accb8ba279 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Fri, 13 Jun 2025 16:11:29 +0100 Subject: [PATCH] fix: resolve Settings modal version display timing issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Make switchTab function async to handle proper timing - Move loadCurrentVersion call to after DOM element creation - Remove redundant version loading from loadConfiguration - Ensures "Current Version" shows actual version instead of "Loading..." 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/public/js/ui/settings.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/public/js/ui/settings.js b/src/public/js/ui/settings.js index 1a3abeec3..bbb907c9a 100644 --- a/src/public/js/ui/settings.js +++ b/src/public/js/ui/settings.js @@ -58,15 +58,15 @@ PulseApp.ui.settings = (() => { const tabButtons = document.querySelectorAll('.settings-tab'); tabButtons.forEach(button => { - button.addEventListener('click', (e) => { + button.addEventListener('click', async (e) => { e.preventDefault(); const tabName = e.currentTarget.getAttribute('data-tab'); - switchTab(tabName); + await switchTab(tabName); }); }); } - function switchTab(tabName) { + async function switchTab(tabName) { // Preserve current form data before switching tabs preserveCurrentFormData(); @@ -91,6 +91,11 @@ PulseApp.ui.settings = (() => { // Update content renderTabContent(); + // Load current version if system tab is active (after DOM element exists) + if (activeTab === 'system') { + await loadCurrentVersion(); + } + // Restore form data for the new tab restoreFormData(); } @@ -107,7 +112,7 @@ PulseApp.ui.settings = (() => { await loadConfiguration(); // Switch to requested tab - switchTab(tabName); + await switchTab(tabName); } function closeModal() { @@ -126,9 +131,6 @@ PulseApp.ui.settings = (() => { const data = await PulseApp.apiClient.get('/api/config'); currentConfig = data; renderTabContent(); - - // Load current version from dynamic API - await loadCurrentVersion(); } catch (error) { PulseApp.apiClient.handleError(error, 'Load configuration', showMessage); }