fix(badges): auto-save font sizes on adjustment

Font size changes now persist automatically (600ms debounce) without
requiring the user to find and click Lock Sizes in the collapsed Staff
section. reset_font_sizes_to_auto continues to handle its own save.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-04-11 19:37:31 -04:00
parent 15566efec1
commit ad3b27b747

View File

@@ -731,6 +731,34 @@ async function reset_font_sizes_to_auto() {
}
}
// --- Auto-save font sizes on change ---
// When a trusted user adjusts font sizes the change is saved automatically after a
// short debounce so they don't have to find and click "Lock Sizes" every time.
// WHY: the Lock Sizes button is in the Staff section (starts collapsed) and users
// routinely adjusted font sizes and then reloaded, losing their changes.
// reset_font_sizes_to_auto handles its own save, so we only auto-save when at
// least one size is non-null (i.e. the "reset to auto" path is excluded here).
let _font_auto_save_timer: ReturnType<typeof setTimeout> | null = null;
$effect(() => {
// Re-read the dirty+override signals inside the effect so Svelte tracks them.
const dirty = sizes_are_dirty;
const has_override = has_any_size_override;
if (!dirty || !has_override || !is_trusted || !$lq__event_badge_obj?.event_badge_id) {
return;
}
if (_font_auto_save_timer !== null) clearTimeout(_font_auto_save_timer);
_font_auto_save_timer = setTimeout(() => {
_font_auto_save_timer = null;
lock_font_sizes();
}, 600);
return () => {
if (_font_auto_save_timer !== null) {
clearTimeout(_font_auto_save_timer);
_font_auto_save_timer = null;
}
};
});
// TC modal ref for the lead scanning terms & conditions dialog
let tc_dialog_ref: HTMLDialogElement | undefined;