Follow-up from the PR #118 review. Mirrors the #114 → #117 precedent (pure extraction for testability).
Background
components/site/Chrome.tsx handleNavClick opens with a 6-flag short-circuit:
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
homeHashSectionId is already extracted + unit-tested (lib/scroll.test.ts), so the only remaining untested decision in the handler is this modifier guard — generic browser-nav etiquette, not #116 logic. The repo has no jsdom / RTL, so the DOM glue (getElementById / scrollIntoView / replaceState / location.assign) intentionally stays untested; this predicate, however, is trivially pure.
Suggested change
// lib/scroll.ts (or a sibling)
export function shouldInterceptNavClick(e: {
defaultPrevented: boolean; button: number;
metaKey: boolean; ctrlKey: boolean; shiftKey: boolean; altKey: boolean;
}): boolean {
return !(e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey);
}
handleNavClick calls it; add a lib/scroll.test.ts block covering: plain left-click → true; each modifier / middle-click / defaultPrevented → false. Zero new infra (Node-env Vitest, existing **/*.test.ts glob). Not blocking — defer until convenient.
Follow-up from the PR #118 review. Mirrors the #114 → #117 precedent (pure extraction for testability).
Background
components/site/Chrome.tsxhandleNavClickopens with a 6-flag short-circuit:homeHashSectionIdis already extracted + unit-tested (lib/scroll.test.ts), so the only remaining untested decision in the handler is this modifier guard — generic browser-nav etiquette, not #116 logic. The repo has no jsdom / RTL, so the DOM glue (getElementById/scrollIntoView/replaceState/location.assign) intentionally stays untested; this predicate, however, is trivially pure.Suggested change
handleNavClickcalls it; add alib/scroll.test.tsblock covering: plain left-click → true; each modifier / middle-click /defaultPrevented→ false. Zero new infra (Node-env Vitest, existing**/*.test.tsglob). Not blocking — defer until convenient.