fix: defensive CSS hidden rule, cache MediaQueryList, guard setSheetSnap

- Add [hidden] { display: none !important } to prevent CSS specificity overrides
- Cache matchMedia query instead of creating new MediaQueryList per call
- Guard setSheetSnap against being called on desktop

Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
Alex-GilbertandClaude Opus 4.6 committed 2026-02-21 16:25:46 -06:00
1 parent 9ad2bc150a
commit c915935ee4
2 files changed
+5 -2

No files matched your search

+4 -2
View File
@@ -16,7 +16,8 @@ import { stopSolve, acceptSolution, initSolver } from './solver.js';
// ── Sheet snap management ──
const isMobile = () => window.matchMedia('(max-width: 768px)').matches;
const mobileQuery = window.matchMedia('(max-width: 768px)');
const isMobile = () => mobileQuery.matches;
const SNAP_PEEK = 60;
const SNAP_HALF_RATIO = 0.45;
@@ -37,6 +38,7 @@ function getSnapHeight(snap) {
function setSheetSnap(snap) {
sheetSnap = snap;
if (!isMobile()) return;
const h = getSnapHeight(snap);
document.documentElement.style.setProperty('--sheet-height', h + 'px');
bottomSheet.style.height = h + 'px';
@@ -153,7 +155,7 @@ function handleLayoutChange() {
}
}
window.matchMedia('(max-width: 768px)').addEventListener('change', handleLayoutChange);
mobileQuery.addEventListener('change', handleLayoutChange);
// ── Font loading ──
+1
View File
@@ -1,4 +1,5 @@
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
:root {
--bg-base: #1a1a2e;