From fd4182563e42b5a83e9fc728c6a38bf6a415d459 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Wed, 5 Nov 2025 20:15:48 +0000 Subject: [PATCH] Fix custom backup polling interval selection not persisting Addresses issue #567 where selecting "Custom interval..." from the backup polling dropdown would revert to a preset option if the current custom minutes value happened to match a predefined interval. The bug occurred because: 1. User selects "Custom interval..." from dropdown 2. Code sets interval based on current customMinutes value 3. If that value matches a preset (e.g., 60 min = 1 hour), the computed select value returns the preset instead of 'custom' 4. Dropdown reverts, hiding the custom input field Fix introduces a dedicated state variable (backupPollingUseCustom) to explicitly track whether custom mode is active, independent of whether the current interval value matches a preset option. Changes: - Add backupPollingUseCustom signal to track custom mode state - Update backupIntervalSelectValue() to check custom flag first - Set/clear custom flag in dropdown onChange handler - Initialize custom flag when loading settings from API Related to #567 --- frontend-modern/src/components/Settings/Settings.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend-modern/src/components/Settings/Settings.tsx b/frontend-modern/src/components/Settings/Settings.tsx index 2c9bb4a..48a9efe 100644 --- a/frontend-modern/src/components/Settings/Settings.tsx +++ b/frontend-modern/src/components/Settings/Settings.tsx @@ -655,9 +655,13 @@ const Settings: Component = (props) => { const [backupPollingEnabled, setBackupPollingEnabled] = createSignal(true); const [backupPollingInterval, setBackupPollingInterval] = createSignal(0); const [backupPollingCustomMinutes, setBackupPollingCustomMinutes] = createSignal(60); + const [backupPollingUseCustom, setBackupPollingUseCustom] = createSignal(false); const backupPollingEnvLocked = () => Boolean(envOverrides()['ENABLE_BACKUP_POLLING'] || envOverrides()['BACKUP_POLLING_INTERVAL']); const backupIntervalSelectValue = () => { + if (backupPollingUseCustom()) { + return 'custom'; + } const seconds = backupPollingInterval(); return BACKUP_INTERVAL_OPTIONS.some((option) => option.value === seconds) ? String(seconds) @@ -1674,6 +1678,9 @@ const Settings: Component = (props) => { if (intervalSeconds > 0) { setBackupPollingCustomMinutes(Math.max(1, Math.round(intervalSeconds / 60))); } + // Determine if the loaded interval is a custom value + const isPresetInterval = BACKUP_INTERVAL_OPTIONS.some((opt) => opt.value === intervalSeconds); + setBackupPollingUseCustom(!isPresetInterval && intervalSeconds > 0); // Load auto-update settings setAutoUpdateEnabled(systemSettings.autoUpdateEnabled || false); setAutoUpdateCheckInterval(systemSettings.autoUpdateCheckInterval || 24); @@ -4115,9 +4122,11 @@ const Settings: Component = (props) => { onChange={(e) => { const value = e.currentTarget.value; if (value === 'custom') { + setBackupPollingUseCustom(true); const minutes = Math.max(1, backupPollingCustomMinutes()); setBackupPollingInterval(minutes * 60); } else { + setBackupPollingUseCustom(false); const seconds = parseInt(value, 10); if (!Number.isNaN(seconds)) { setBackupPollingInterval(seconds);