Skip to content

fix(calendar): calendar day selection and month navigation not updating - #421

Open
shakurt wants to merge 4 commits into
feat/free-widget-canvasfrom
fix/calendar-date-selection-not-updating
Open

fix(calendar): calendar day selection and month navigation not updating#421
shakurt wants to merge 4 commits into
feat/free-widget-canvasfrom
fix/calendar-date-selection-not-updating

Conversation

@shakurt

@shakurt shakurt commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Problem

In the default UI, clicking a calendar day or the prev/next month buttons did nothing —
no re-render, no error, no network request. The popup always showed today's date/events
regardless of which day was clicked.

Root cause

The calendar widget in widgetItems (used by the default/ADVANCED UI's ContentSection)
rendered <CalendarLayout /> without a DateProvider ancestor, unlike the
WIDGET_DEFINITIONS entry used by the custom canvas UI. Without the provider, every
useDate() call silently fell back to a stub where setSelectedDate/setCurrentDate
are no-ops and selectedDate/currentDate are recomputed to "now" on every render —
so nothing the user clicked could ever change the displayed date.

Changes

  • fix(calendar): wrap the default-UI calendar widget with DateProvider
    (the actual fix for the reported bug).
  • fix(calendar): ClickableTooltip was attaching its own native capture-phase click
    listener (with stopPropagation) on the trigger element, racing with DayItem's own
    onClick. Added a toggleOnTriggerClick opt-out and disabled it for the calendar, and
    pass selectedDate into CalendarDayDetails as an explicit prop instead of
    re-deriving it from context.
  • perf(date-context): memoized DateProvider's context value/callbacks so consumers
    don't re-render on unrelated parent re-renders.

Testing

Manually verified in bun dev: clicking different days updates the popup content
correctly, and prev/next/today navigation works.

… clicks

ClickableTooltip attached its own native capture-phase click listener
(with stopPropagation) directly on the trigger element to toggle open
state. In the calendar, DayItem already has its own onClick that opens
the tooltip explicitly, so the two handlers raced and the native
listener could swallow the day cell's React onClick after the first
click. Added a toggleOnTriggerClick opt-out and disabled it for the
calendar's usage, and pass selectedDate into CalendarDayDetails as an
explicit prop instead of re-deriving it from context.
The calendar widget in widgetItems (used by the default/ADVANCED UI's
ContentSection) rendered <CalendarLayout /> without a DateProvider
ancestor, unlike the WIDGET_DEFINITIONS entry used by the custom
canvas UI. Without the provider, every useDate() call fell back to a
stub where setSelectedDate/setCurrentDate are no-ops and
selectedDate/currentDate are recomputed to "now" on every render. That
silently broke day selection and month navigation with no console
errors, since the calendar was pinned to whatever "today" resolves to
on each render.
goToToday, isToday and getHijriDate were recreated on every render,
and the context value object was a fresh literal each time, so every
consumer of useDate() re-rendered whenever DateProvider re-rendered
for any reason, even when none of currentDate/selectedDate/today
actually changed. Wrapped the callbacks in useCallback and the
provided value in useMemo, keyed on their real dependencies.
…NITIONS

widget-visibility.context.tsx is being phased out in favor of
widget-registry.tsx, and duplicating the DateProvider wrap here was
redundant with WIDGET_DEFINITIONS[calendar].node, which already wraps
CalendarLayout correctly. Point the old registry's calendar entry at
the new one instead of maintaining two copies of the same wiring.
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