From 924085ebb2d74c6109f8726e2cd4ea2f12d2841c Mon Sep 17 00:00:00 2001 From: chriscarrollsmith Date: Tue, 23 Jun 2026 11:12:12 -0400 Subject: [PATCH] refactor: inline syncSubPreferences into master change handler The syncSubPreferences helper was only invoked from the master checkbox's change handler (disable branch) and never on init, where initial visibility is already set server-side via Jinja. Inlining it removes the indirection and the asymmetry between the enable and disable paths while preserving behavior: enabling reveals the sub-preferences and checks updates; disabling hides them and clears both sub-preferences. Co-authored-by: Cursor --- .../partials/communication_preferences_fields.html | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/templates/partials/communication_preferences_fields.html b/templates/partials/communication_preferences_fields.html index 928c6bc..14d60a4 100644 --- a/templates/partials/communication_preferences_fields.html +++ b/templates/partials/communication_preferences_fields.html @@ -54,23 +54,15 @@ return; } - function syncSubPreferences() { + master.addEventListener('change', function () { if (master.checked) { subPrefs.style.display = ''; + updates.checked = true; } else { subPrefs.style.display = 'none'; updates.checked = false; marketing.checked = false; } - } - - master.addEventListener('change', function () { - if (master.checked) { - subPrefs.style.display = ''; - updates.checked = true; - } else { - syncSubPreferences(); - } }); }); })();