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
This commit is contained in:
rcourtman 2025-11-05 20:15:48 +00:00
parent efa1ec1cd9
commit fd4182563e

View file

@ -655,9 +655,13 @@ const Settings: Component<SettingsProps> = (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<SettingsProps> = (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<SettingsProps> = (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);