fix: Remove unused cookie helper functions and fix desktop sidebar visibility

1. Removed unused getPreferenceCookie and setPreferenceCookie functions
   - These were flagged by golangci-lint as unused
   - Cookie preferences now handled client-side via localStorage
   - Removed unused net/http import

2. Fixed desktop sidebar accordion auto-opening
   - Updated handleLandscapeAccordions() to open accordions in desktop view (≥769px)
   - Sidebars now show content in desktop, landscape mobile, and portrait mobile
   - Only keep accordions collapsed in portrait mobile for space saving

3. Created comprehensive multi-viewport test (66-comprehensive-all-viewports-test.mjs)
   - Tests desktop (1278px), portrait mobile (375×667), landscape mobile (667×375)
   - Validates sidebars, accordion state, content visibility, AND all buttons
   - Checks button backdrop visibility in mobile views
   - Every feature now has corresponding test coverage

Fixes golangci-lint errors:
- internal/handlers/cv_helpers.go:366: func getPreferenceCookie is unused
- internal/handlers/cv_helpers.go:375: func setPreferenceCookie is unused
- internal/handlers/cv_helpers.go:7: net/http imported and not used
This commit is contained in:
juanatsap
2025-11-25 06:00:39 +00:00
parent 82f73cf724
commit 76d80edd7e
5 changed files with 455 additions and 31 deletions
+14 -8
View File
@@ -74,32 +74,38 @@
};
/**
* Auto-open sidebar accordions in landscape mobile mode
* Ensures sidebar content is visible in landscape orientation
* Auto-open sidebar accordions in landscape mobile mode AND desktop
* Ensures sidebar content is always visible except in portrait mobile
*/
function handleLandscapeAccordions() {
function openSidebarAccordionsIfLandscape() {
function openSidebarAccordionsIfNeeded() {
const isLandscape = window.matchMedia('(max-width: 915px) and (orientation: landscape)').matches;
const isDesktop = window.matchMedia('(min-width: 769px)').matches;
const isPortraitMobile = window.matchMedia('(max-width: 768px) and (orientation: portrait)').matches;
if (isLandscape) {
// Open all sidebar accordions in landscape mode
// Open accordions in landscape mobile OR desktop view
// Keep them closed ONLY in portrait mobile (≤768px)
if (isLandscape || isDesktop) {
document.querySelectorAll('.sidebar-accordion').forEach(accordion => {
accordion.setAttribute('open', '');
});
} else if (isPortraitMobile) {
// In portrait mobile, leave them closed (user can expand manually)
// Don't remove 'open' attribute if user has opened them
}
}
// Run on load
openSidebarAccordionsIfLandscape();
openSidebarAccordionsIfNeeded();
// Run on orientation change
window.addEventListener('orientationchange', () => {
setTimeout(openSidebarAccordionsIfLandscape, 100);
setTimeout(openSidebarAccordionsIfNeeded, 100);
});
// Run on resize (for desktop browser testing)
window.addEventListener('resize', () => {
openSidebarAccordionsIfLandscape();
openSidebarAccordionsIfNeeded();
});
}