Skip to content

fix(calendar): the view switch lights an option a phone cannot render #331

Closed

Description

@sydevs-bot

Summary

On a phone the calendar's Month button is lit while the body shows the day list, and clicking Month cannot change it. Schedule-X moves itself off month-grid when it mounts below its breakpoint, because that view declares no small-screen support, and nothing tells our own view switch. Measured on sahajatlas.com/calendar, headless Chromium: at 390×844 .sx__view-container's child is sx__list-wrapper while the switch shows Month; at 1280×900 the same state gives sx__month-grid-wrapper.

Decisions

  • What should "Month" offer on a phone? → A: register createViewMonthAgenda() for small screens, so Month shows a month date-picker over the selected day's agenda and the switch keeps three options at every width (Ardnived, 2026-10-25)
  • What should "Week" offer on a phone? → A: hide Week below the crossing, so the switch offers two options there and three above it. Schedule-X ships no small-screen week, and a 7-column time grid at 390px was never readable (Ardnived, 2026-10-26)

Approach

What Schedule-X actually does

Read from the pinned 2.36.0 build, node_modules/@schedule-x/calendar/dist/core.js:

registered view hasSmallScreenCompat hasWideScreenCompat wrapper class
month-grid false true sx__month-grid-wrapper
week false true sx__week-wrapper
list true true sx__list-wrapper
month-agenda (not registered) true false sx__month-agenda-wrapper
day (not registered) true true sx__week-wrapper

setScreenSizeCompatibleView (core.js:2442) is the only place either flag is enforced on the rendered view, and handleWindowResize is its only caller — once at mount and afterwards only when the small/wide state changes. When the current view lacks the flag for the new state, it switches to the first registered view that has it. Registration order is [month-grid, week, list] (src/views/CalendarView/CalendarView.tsx:303), so the first small-compat view is list — the measured sx__list-wrapper.

Four things that follow, and that the fix is built against:

  • controls.setView() never checks either flag (@schedule-x/calendar-controls, setView): it validates that the name is registered, then sets it. An explicit click therefore does render month-grid at 390×844. The collapse is a mount-time and crossing-time rewrite, not a per-click refusal.
  • week is refused on small screens too. The switch loses Month and Week on a phone mount, from one root cause, so both belong in this fix.
  • SX 2.36 exposes no view-change callback. CalendarCallbacks (core.d.ts) has onSelectedDateUpdate, onRangeUpdate and the click callbacks, and nothing for the view. The rewrite cannot be observed, so it has to be prevented: never let SX pick a view.
  • isResponsive: false removes the rewrite outright, and this app loses nothing by it. The resize listener is registered only if ($app.config.isResponsive) (core.js:2541), and that is the only path into setScreenSizeCompatibleView, so both the mount rewrite and the crossing rewrite disappear. isCalendarSmall then stays undefined (core.js:4638), and its only two readers are SX's own view dropdown (ViewSelection, core.js:1122) and the sx__is-calendar-small class — whose three rules in @schedule-x/theme-default all target SX's header chrome (sx__forward-backward-navigation, sx__range-heading, sx__today-button), and this app hides that header (src/styles/globals.css:532). Neither compat flag is then consulted anywhere, so the resolver below is the only thing that decides, with no registration order to depend on and no race between SX's own resize listener and this app's damped ResizeObserver signal (SETTLE_MS, src/config/responsive.ts).

Why clicking Month cannot recover it today: the switch's value is already VIEW_MONTH on a phone (:150, the store's null ?? VIEW_MONTH), so Radix's single-value ToggleGroup reads the click as a deselect and emits '', which selectView drops (:121). Keep that guard — the value must stop lying, rather than an empty value being let through.

The fix

  1. A pure resolver in src/lib/shape/calendar.ts, beside eventsToCalendarEntries: given a stored view name and a width class, return both the SX view name to render and the option the switch lights.

    stored at or above 768px below 768px
    month-grid (also null) month-grid, Month lit month-agenda, Month lit
    week week, Week lit month-agenda, Month lit
    list list, List lit list, List lit

    week collapses onto month-agenda rather than list because it is the one small-screen view that keeps a chosen day's own hours in view, which is what Week was being read for; it also leaves one answer below the crossing for every non-list view. Never write a width-specific name into the store, so a stored week survives a trip through a phone width and lights Week again above the crossing. The resolver belongs in lib/shape because the node lane can test it — src/views/CalendarView cannot be driven across the crossing, as jsdom has no ResizeObserver (src/config/responsive.ts).

  2. Register the fourth view and turn SX's own responsiveness off (:303): views: [createViewMonthGrid(), createViewMonthAgenda(), createViewWeek(), createViewList()], plus isResponsive: false. controls.setView validates the name against that list, so month-agenda has to be registered even though the resolver, never SX, chooses it.

  3. Resolve at the three seams in CalendarView.tsx: defaultView (:305), selectView's controls.setView (:120), and the ToggleGroup's value (:150). useIsWideWidget() is the single signal — CalendarControls and CalendarGrid both sit under WidgetWidthContext. CalendarGrid captures its config once at mount, so the crossing needs an effect of its own: when the resolved SX name changes, drive controls.setView to it. Nothing competes with that call once step 2 lands.

  4. Hide the Week option below the crossing (:154), and read the resolved option — not the stored name — in label (:105) and step (:128). Both branch on VIEW_WEEK, so a stored week on a phone would otherwise label the week's first day and page by whole weeks while a month agenda renders.

  5. Wire onClickAgendaDate (core.d.ts:300, emitted at core.js:5939) to useCalendarPosition.setDate, beside the other callbacks (:317). onSelectedDateUpdate is emitted only from the date picker's own change callback (createDateSelectionCallback), so a day picked in the agenda grid would otherwise leave the header's date label behind.

  6. src/views/DrawerStack/DrawerStack.tsx:307 picks the full-width drawer from the stored view (calendarView !== 'list'). Read the resolved option there instead, from the isWide it already has: month-agenda is a single narrow column, like the list view that test already excludes. The same test also hides the settings cog (:806), so today a phone in month view has no cog at all.

No new translation key is needed: the switch keeps calendar.view_month and calendar.view_week (:153, :154), and hiding a button needs no copy. No new CSS either — @schedule-x/theme-default ships the sx__month-agenda-* rules, and globals.css:542 already names .sx__month-agenda-event.

Acceptance criteria

  • At 390×844 every option the view switch offers renders a visibly different body, and the lit option matches what rendered — at first paint, before any click, as well as after one.
  • Below the crossing the switch offers Month and List. At or above it, Month, Week and List.
  • At 1280×900 the three views behave exactly as they do today.
  • A stored view the current width cannot render resolves to one that can, rather than lighting a button that does nothing. This holds across a grid remount — a filter apply, or returning from an event — and across a resize over the crossing in both directions, restoring the stored view wherever the width allows it.

Verification checklist

  • Playwright at 390×844 and at 1280×900: read the class of .sx__view-container's first child at first paint, then after clicking each option in turn. No two options share a class at either size. At 390 the switch has two options and Month gives sx__month-agenda-wrapper; at 1280 it has three and Month gives sx__month-grid-wrapper.
  • Playwright at 390×844: select Month, apply a filter to remount the keyed grid, and confirm the lit button still matches the rendered body.
  • Playwright: select Week at 1280×900, resize to 390×844 — sx__month-agenda-wrapper renders and Month is lit — then resize back and confirm Week is lit over sx__week-wrapper.
  • Playwright at 390×844 in Month view: the settings cog renders (DrawerStack's wide test).
  • pnpm test:run src/lib/shape/calendar with cases over the stored-view × width mapping in both directions, including the list pass-through and the week collapse.
  • .claude/skills/pr-prep/check.sh

Notes

Found while verifying #319 on a phone viewport (2026-10-25). Unrelated to #319's own root cause — the drawer panel being a scroll container — which #326 and PR #328 fix.

Registering createViewDay() and mapping Week → Day below the crossing was the rejected option B for question 2. day renders sx__week-wrapper, so Week and Day are indistinguishable by wrapper class, and a button saying Week over a single day needs a new label — translations are CMS-owned, so it would have waited on a sydevs/SahajCloud issue.

sx__is-calendar-small, Schedule-X's own class on .sx__calendar-wrapper, is a styling marker only. It never gated which view renders; setScreenSizeCompatibleView did, and isResponsive: false retires both.

useCalendarPosition is a plain zustand store with no persistence middleware, and src/config/store.ts:159 says so: the view and date are session-scoped and clear on reload. So a reload cannot reproduce a stale stored view — a remount can, which is why the criteria and the checklist name a filter apply rather than a reload.

Activity

  1. added theissue type on Oct 25, 2026
  2. added
    proposal
    on Oct 25, 2026
  3. Ardnived commented on Oct 25, 2026

    @Ardnived
    Contributor

    @sydevs-bot revise 1A

  4. removed
    proposal
    on Oct 25, 2026
  5. moved this from Proposed to Revising in SYDevelopers Technical Roadmapon Oct 25, 2026
  6. added
    bot:working
    on Oct 25, 2026
  7. sydevs-bot commented on Oct 25, 2026

    @sydevs-bot
    ContributorAuthor

    🤖 no session running

    recent dispatches
    • 00:09Z implement · attempt 1 · session · done
    • 00:09Z implement · attempt 1 · session
    • 23:53Z revise · attempt 1 · session · done
    • 23:53Z revise · attempt 1 · session
    • 20:54Z revise · attempt 1 · session · done

    Written by the sydevs dispatcher. Sessions never edit this comment.

  8. changed the title [-]fix(calendar): the Month toggle renders the day list on a phone[/-] [+]fix(calendar): the view switch lights an option a phone cannot render[/+] on Oct 25, 2026
  9. sydevs-bot commented on Oct 25, 2026

    @sydevs-bot
    ContributorAuthor

    Applied 1A: Month registers createViewMonthAgenda() below the crossing. Moved to ## Decisions.

    Rewrote ## Approach from the pinned 2.36.0 build. Three corrections:

    • SX refuses no view per click. controls.setView() only validates the name. The rewrite happens in setScreenSizeCompatibleView, at mount and at each breakpoint crossing, to the first registered compat view — list today.
    • week declares hasSmallScreenCompat: false too, so Week lies on a phone from the same cause. Folded in.
    • useCalendarPosition has no persistence (src/config/store.ts:159), so a reload cannot reproduce a stale view. The criteria name a remount instead.

    New open question 2: what Week offers on a phone. SX ships no small-screen week, and month-agenda survives only where isCalendarSmall is truthful, so week cannot be emitted below the crossing. Recommended A — hide Week there.

    Title broadened; the fix is no longer Month-only. Type and Priority unchanged.

    @sydevs-bot implement starts the build, once 2 is answered.

    🤖 Written by the sydevs autonomous loop — see what this is


    Generated by Claude Code

  10. removed
    bot:working
    on Oct 25, 2026
  11. 3 remaining items

  12. sydevs-bot commented on Oct 26, 2026

    @sydevs-bot
    ContributorAuthor

    Not started: 1 open question(s) in the body still need an answer. Reply @sydevs-bot revise with your choices (for example 1A), then say @sydevs-bot implement again.

    🤖 sydevs dispatcher

  13. Ardnived commented on Oct 26, 2026

    @Ardnived
    Contributor

    @sydevs-bot revise 2A

  14. added
    bot:working
    and removed on Oct 26, 2026
  15. sydevs-bot commented on Oct 27, 2026

    @sydevs-bot
    ContributorAuthor

    Applied 2A: Week is hidden below the crossing. Moved to ## Decisions, and no open question remains.

    One correction from the pinned 2.36.0 build. The fix no longer pins SX's breakpoint through isCalendarSmall — it sets isResponsive: false. The resize listener is registered only when that flag is on (core.js:2541), and it is the only path into setScreenSizeCompatibleView, so nothing can rewrite the view mid-resize and the resolver becomes the only authority. The dropped signal has two readers, both in SX's own header, which globals.css:532 hides.

    The resolver maps a stored week to month-agenda below the crossing and lights Month. The store keeps week, so widening restores it. label and step read the resolved option too, or a phone pages by whole weeks over a month agenda.

    Type, title and Priority unchanged.

    @sydevs-bot implement starts the build.

    🤖 Written by the sydevs autonomous loop — see what this is


    Generated by Claude Code

  16. added and removed
    bot:working
    on Oct 27, 2026
  17. Ardnived commented on Oct 27, 2026

    @Ardnived
    Contributor

    @sydevs-bot implement

  18. moved this from Revising to Approved in SYDevelopers Technical Roadmapon Oct 27, 2026
  19. added
    bot:working
    on Oct 27, 2026
  20. removed
    bot:working
    on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Medium

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions