From fbc270278e12d1c995df799bb0b3fbfba47cf139 Mon Sep 17 00:00:00 2001 From: juanatsap Date: Sun, 16 Nov 2025 17:58:48 +0000 Subject: [PATCH] fix: restore toggle synchronization using hyperscript 'or' operator **Problem**: Toggles in action bar and hamburger menu were not synchronizing. When user clicked one toggle, the other didn't update. **Root Cause**: After restoring toggle functions, they were setting BOTH checkboxes explicitly instead of using the hyperscript 'or' operator pattern from the working version. **Fix**: Restored the original pattern from commit d4ef91b: - Use `set otherToggle to (#lengthToggle or #lengthToggleMenu)` - This dynamically selects "the other" toggle (not the one being clicked) - Simplified code: removed redundant null checks for both checkboxes - Fixed all 3 toggles: toggleCVLength, toggleIcons, toggleTheme **Benefits**: - Toggles now properly sync between action bar and menu - Cleaner, more maintainable code - Matches the proven working pattern **Reference**: Compared with working version at commit d4ef91b --- static/hyperscript/functions._hs | 58 ++++++-------------------------- 1 file changed, 11 insertions(+), 47 deletions(-) diff --git a/static/hyperscript/functions._hs b/static/hyperscript/functions._hs index 8115b04..c77204b 100644 --- a/static/hyperscript/functions._hs +++ b/static/hyperscript/functions._hs @@ -132,90 +132,54 @@ end def toggleCVLength(isLong) set paper to the first .cv-paper - set lengthCheckbox to the first #lengthToggle - set menuLengthCheckbox to the first #lengthToggleMenu + set otherToggle to (#lengthToggle or #lengthToggleMenu) - -- Update DOM state if isLong is true remove .cv-short from paper add .cv-long to paper - if lengthCheckbox exists - set lengthCheckbox's checked to true - end - if menuLengthCheckbox exists - set menuLengthCheckbox's checked to true - end call localStorage.setItem('cv-length', 'long') + if otherToggle exists set otherToggle's checked to true end if isLong is false remove .cv-long from paper add .cv-short to paper - if lengthCheckbox exists - set lengthCheckbox's checked to false - end - if menuLengthCheckbox exists - set menuLengthCheckbox's checked to false - end call localStorage.setItem('cv-length', 'short') + if otherToggle exists set otherToggle's checked to false end end def toggleIcons(showIcons) set paper to the first .cv-paper - set iconsCheckbox to the first #iconToggle - set menuIconsCheckbox to the first #iconToggleMenu + set otherToggle to (#iconToggle or #iconToggleMenu) - -- Update DOM state if showIcons is true add .show-icons to paper - if iconsCheckbox exists - set iconsCheckbox's checked to true - end - if menuIconsCheckbox exists - set menuIconsCheckbox's checked to true - end - call localStorage.setItem('cv-icons', 'show') + call localStorage.setItem('cv-icons', 'true') + if otherToggle exists set otherToggle's checked to true end if showIcons is false remove .show-icons from paper - if iconsCheckbox exists - set iconsCheckbox's checked to false - end - if menuIconsCheckbox exists - set menuIconsCheckbox's checked to false - end - call localStorage.setItem('cv-icons', 'hide') + call localStorage.setItem('cv-icons', 'false') + if otherToggle exists set otherToggle's checked to false end end def toggleTheme(isClean) set container to the first .cv-container - set themeCheckbox to the first #themeToggle - set menuThemeCheckbox to the first #themeToggleMenu + set otherToggle to (#themeToggle or #themeToggleMenu) - -- Update DOM state if isClean is true add .theme-clean to container - if themeCheckbox exists - set themeCheckbox's checked to true - end - if menuThemeCheckbox exists - set menuThemeCheckbox's checked to true - end call localStorage.setItem('cv-theme', 'clean') + if otherToggle exists set otherToggle's checked to true end if isClean is false remove .theme-clean from container - if themeCheckbox exists - set themeCheckbox's checked to false - end - if menuThemeCheckbox exists - set menuThemeCheckbox's checked to false - end call localStorage.setItem('cv-theme', 'default') + if otherToggle exists set otherToggle's checked to false end end