diff --git a/frontend/src/lib/components/AutoRefresh.svelte b/frontend/src/lib/components/AutoRefresh.svelte index 7168345..c0f1f13 100644 --- a/frontend/src/lib/components/AutoRefresh.svelte +++ b/frontend/src/lib/components/AutoRefresh.svelte @@ -19,19 +19,15 @@ }); let intervalId; - let settings; - - $: { - if (pageId) { - settings = getPageAutoRefresh(pageId); - autoRefreshStore.set(settings); - } - } + let initialized = false; function handleIntervalChange(optKey) { const value = Number(options.byKey(optKey)); - autoRefreshStore.setEnabled(value > 0); - autoRefreshStore.setInterval(value); + // batch the update to prevent multiple reactive triggers + autoRefreshStore.set({ + enabled: value > 0, + interval: value + }); } const startAutoRefresh = () => { @@ -52,7 +48,8 @@ } }; - $: if ($autoRefreshStore) { + // reactive statement to handle store changes and persist to localStorage + $: if (initialized && $autoRefreshStore) { startAutoRefresh(); if (pageId) { setPageAutoRefresh(pageId, $autoRefreshStore); @@ -60,7 +57,13 @@ } onMount(() => { - startAutoRefresh(); + // load saved settings from localStorage only once on mount + if (pageId) { + const settings = getPageAutoRefresh(pageId); + autoRefreshStore.set(settings); + } + // mark as initialized to enable reactive statement which will start auto-refresh + initialized = true; }); onDestroy(() => { diff --git a/frontend/src/lib/components/TextFieldSelect.svelte b/frontend/src/lib/components/TextFieldSelect.svelte index fd25d6a..56574af 100644 --- a/frontend/src/lib/components/TextFieldSelect.svelte +++ b/frontend/src/lib/components/TextFieldSelect.svelte @@ -111,6 +111,8 @@ const closeDropdown = () => { showDropdown = false; hasTyped = false; // Reset typing flag when closing + // only clear activeFormElement if it was set by this component + activeFormElement.update((current) => (current === id ? null : current)); }; // Update dropdown position for fixed positioning diff --git a/frontend/src/routes/dashboard/+page.svelte b/frontend/src/routes/dashboard/+page.svelte index 6db3928..62f1761 100644 --- a/frontend/src/routes/dashboard/+page.svelte +++ b/frontend/src/routes/dashboard/+page.svelte @@ -58,8 +58,11 @@ const handleAutoRefreshChange = (optKey) => { const value = Number(autoRefreshOptions.byKey(optKey)); - autoRefreshStore.setEnabled(value > 0); - autoRefreshStore.setInterval(value); + // batch the update to prevent multiple reactive triggers + autoRefreshStore.set({ + enabled: value > 0, + interval: value + }); setPageAutoRefresh('dashboard', $autoRefreshStore); startAutoRefresh(); }; diff --git a/frontend/src/routes/dashboard/events/+page.svelte b/frontend/src/routes/dashboard/events/+page.svelte index aeee568..3d46a6a 100644 --- a/frontend/src/routes/dashboard/events/+page.svelte +++ b/frontend/src/routes/dashboard/events/+page.svelte @@ -56,8 +56,11 @@ const handleAutoRefreshChange = (optKey) => { const value = Number(autoRefreshOptions.byKey(optKey)); - autoRefreshStore.setEnabled(value > 0); - autoRefreshStore.setInterval(value); + // batch the update to prevent multiple reactive triggers + autoRefreshStore.set({ + enabled: value > 0, + interval: value + }); setPageAutoRefresh('dashboard-events', $autoRefreshStore); };