Skip to content

feat(calendar): auto-scroll day/week views to current time on open - #259

Merged
h4yfans merged 2 commits into
mainfrom
wonderful-pike-f76d67
Apr 17, 2026
Merged

feat(calendar): auto-scroll day/week views to current time on open#259
h4yfans merged 2 commits into
mainfrom
wonderful-pike-f76d67

Conversation

@h4yfans

@h4yfans h4yfans commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

What

Auto-scroll calendar day and week views so the current-time indicator lands near the top of the viewport when the user opens the page, instead of stranding them at midnight.

Why

Users opening day or week view saw 00:00 at the top of the scroll container. The "now" indicator was rendered, but off-screen — they had to scroll down to find the present time. On a 24h × 96px-per-hour timeline (2304px), that's a meaningful hit on every view open / navigation.

Requested behavior: current time at roughly 40% from the top (40% past / 60% future visible).

How

  • New shared hook use-scroll-to-current-time.ts that sets scrollTop = currentOffset - viewportHeight * 0.4 via useLayoutEffect (pre-paint, no flash of midnight).
  • Wired a dedicated scrollRef into each view's overflow-y-auto container. Could not reuse the existing gridRef because it's attached to the inner grid (for marquee bounding-box math), not the scroll viewport.
  • Re-runs on the boolean containsToday, not on every date change — so paging through future days preserves the user's manual scroll position; the snap only re-applies when crossing the today boundary.
  • Fallback: if today is not in the visible range (e.g. future week, past day), scroll to 7 AM instead of 0:00.
  • Pre-commit hook tweak: exempt root CHANGELOG.md from the 800-line module limit. The existing hook already exempts tests/generated files; an append-only historical log belongs in the same category.

Type

  • feat — new feature

Test plan

  • Manual testing — verified by running the app, opening day/week views on today and on non-today dates, and confirming scroll position matches the spec.
  • Unit tests — none added; the hook is a thin DOM side-effect around scrollTop math that's hard to meaningfully unit-test without a real layout engine. Happy to add jsdom coverage if preferred.

Checklist

  • Self-reviewed the diff
  • No hardcoded secrets or credentials
  • Files stay under ~500 LOC
  • Follows immutable data patterns

h4yfans added 2 commits April 17, 2026 15:03
CHANGELOG.md is an append-only historical log with no splitting path.
The existing hook already exempts tests, generated files, and node_modules;
root-level CHANGELOG belongs in the same category.
Users opening day or week view landed at midnight and had to scroll to
find the current-time indicator. A useLayoutEffect now positions the
scroll container so "now" sits ~40% from the top (40% past / 60%
future), with a 7 AM fallback when today is not in the visible range.
@h4yfans
h4yfans merged commit a1e7159 into main Apr 17, 2026
2 checks passed
h4yfans added a commit that referenced this pull request May 6, 2026
feat(calendar): auto-scroll day/week views to current time on open
@h4yfans
h4yfans deleted the wonderful-pike-f76d67 branch May 6, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant