Skip to content

feat(calendar): context-aware sidebar date clicks (Calendar view vs Journal) - #269

Merged
h4yfans merged 1 commit into
mainfrom
exciting-diffie-39077e
Apr 17, 2026
Merged

feat(calendar): context-aware sidebar date clicks (Calendar view vs Journal)#269
h4yfans merged 1 commit into
mainfrom
exciting-diffie-39077e

Conversation

@h4yfans

@h4yfans h4yfans commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

What

The global right-sidebar mini-calendar now behaves based on the active tab:

Active tab Sidebar day click
Calendar Re-anchors the current calendar view (day/week/month/year) in place
Anything else Opens/focuses Journal at that date (unchanged)

The Today button in the sidebar follows the same branch.

Why

Before this change, every sidebar day click navigated to the Journal tab — disruptive when the user is actively working in Calendar, since it yanked them out of their Month/Week/Year view just to focus a date. Making the sidebar context-aware lets the same UI serve both workflows: fast navigation inside Calendar, and quick journaling from anywhere else.

How

  • New CalendarViewContext (apps/desktop/src/renderer/src/contexts/calendar-view-context.tsx) — holds the single anchorDate shared between CalendarPage and GlobalDayPanel. Mirrors the DayPanelContext pattern (null sentinel + throwing hook).
  • GlobalDayPanel branches handleDateSelect / handleTodayClick on useActiveTab()?.type === 'calendar'.
  • CalendarPage swaps its local useState(getTodayDate) for useCalendarView(). No other handler changes — the React useState setter identity is preserved through context, so setAnchorDate((current) => ...) functional updates in handlePrevious / handleNext keep working.
  • All four views handled by one branch: getRangeForView(view, anchorDate) already derives day/week/month/year ranges from a single anchor, so setting anchorDate = clickedDate re-centers whichever view is active. No per-view code.
  • Test wrapper updated: tests/utils/render.tsx wraps the new provider inside the existing DayPanelProvider — one edit fixed all 3 calendar test files without per-test churn.

Type

  • feat — new feature

Test plan

  • Unit tests updated (central renderWithProviders wrapper)
  • Manual testing TODO:
    • Notes tab → click sidebar day → Journal opens at date (regression)
    • Journal tab → click sidebar day → Journal re-focuses date (regression)
    • Calendar / Month view → click sidebar day in another month → Month view scrolls, no tab switch
    • Calendar / Week view → click sidebar day → week grid re-centers
    • Calendar / Year view → click sidebar day in another year → year grid changes
    • Calendar / Day view → click sidebar day → Day view and sidebar stay in sync
    • Today button from Calendar tab → anchor jumps to today, no tab switch
  • Verification run in this branch: pnpm --filter desktop typecheck:web clean, pnpm lint 0 errors, pnpm test6912 passed, 0 failed.

Checklist

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

The global right-sidebar mini-calendar previously always navigated to
the Journal tab on day click. When the user is actively working in the
Calendar tab this was disruptive — it yanked them out of their
Month/Week/Year view just to focus a date.

Make the sidebar context-aware: when the Calendar tab is the active
tab, clicking a day (or the Today button) re-anchors the current
calendar view in place, without a tab switch. All four views
(day/week/month/year) are handled by the existing anchor-driven range
logic — no per-view branching. For every other active tab, behavior is
unchanged (opens Journal at that date).

- New CalendarViewContext shares anchorDate across CalendarPage and
  GlobalDayPanel so the sidebar can drive the view.
- GlobalDayPanel branches handleDateSelect/handleTodayClick on
  useActiveTab()?.type === 'calendar'.
- Central test wrapper (renderWithProviders) wraps the new provider so
  existing CalendarPage tests continue to render.
@h4yfans
h4yfans merged commit 14752d1 into main Apr 17, 2026
5 checks passed
h4yfans added a commit that referenced this pull request Apr 18, 2026
The renderer-level week-view quick-create test fought two jsdom limitations
after main merged in the virtualized horizontal scroll (PR #269-era change):
the week grid now keys popover rendering on absolute day indices via
@tanstack/react-virtual, which needs ResizeObserver + real box geometry to
render any visible columns. jsdom's zero-sized layout produces no visible
virtual items, so the popover never mounts.

The Electron E2E test already covers the week-view quick-create flow against
a real Chromium runtime with real layout. Drop the renderer-layer duplicate
and leave a comment explaining why.
h4yfans added a commit that referenced this pull request Apr 18, 2026
The renderer-level week-view quick-create test fought two jsdom limitations
after main merged in the virtualized horizontal scroll (PR #269-era change):
the week grid now keys popover rendering on absolute day indices via
@tanstack/react-virtual, which needs ResizeObserver + real box geometry to
render any visible columns. jsdom's zero-sized layout produces no visible
virtual items, so the popover never mounts.

The Electron E2E test already covers the week-view quick-create flow against
a real Chromium runtime with real layout. Drop the renderer-layer duplicate
and leave a comment explaining why.
@h4yfans
h4yfans deleted the exciting-diffie-39077e 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