Skip to content

fix(bases): follow the date across midnight in open views (#2504) - #2506

Merged
callumalpass merged 1 commit into
mainfrom
fix/2504-bases-date-rollover
Nov 5, 2026
Merged

callumalpass merged 1 commit into
mainfrom
fix/2504-bases-date-rollover

Conversation

@callumalpass

Copy link
Copy Markdown
Owner

Refs #2504

Problem

Nothing in src/bases listens for date-changed, so a view left open across midnight keeps the previous day's state until its rows change.

Reproduction (unmodified origin/main, isolated Obsidian 1.15.0)

The renderer clock was shifted a day ahead and the plugin's own 60-second detector emitted date-changed.

Claim in the issue Result
List and Kanban keep old labels and classes Confirmed: due: Nov 6 17:25 with --future at +64s, same DOM nodes. Any render fixes it (Today at 17:25)
Calendar keeps the old first day Confirmed: still started on the old day at +64s; a reopened control started on the new day
Unchanged-rows Bases update does not redraw the calendar Confirmed
Calendar today marks and cards stay stale Not reproduced: @tasknotes/calendar rebuilds itself on its minute tick when the day changes, so is-today moved and cards remounted without TaskNotes

Not in the issue: with showOverdueOnToday, a task that had just become overdue stayed on the old day, because items are projected from now and only a refetch moves them.

Fix

  • registerBasesDateRollover owns the listener. It redraws a view that has a layout box. A view without one (for example a background tab) waits on a one-shot ResizeObserver until it is shown, then catches up once however many days passed.
  • BasesViewBase redraws through onDataUpdated, so Kanban and Task List keep their mid-drag guards. Task List needed no card changes because buildCardRenderSignature already includes targetDate. This also covers Mini Calendar.
  • CalendarView overrides the hook, since its onDataUpdated deliberately skips unchanged rows. A calendar still on the old day moves to today and keeps its scroll position; any other calendar stays where it is. Both refetch items, once.
  • onDataUpdated itself is unchanged.
  • Cost is one ordinary render per visible view per day, and no work at all for hidden views. Listeners and any pending observer are removed on unload. Bases filters using today() are out of scope.

Please check

  • Configured dates: a calendar with initialDate or initialDateProperty set does not move, even if it is on the old day. Otherwise a calendar embedded in a daily note would leave that note's date at midnight.
  • Selection: moving into a new range goes through onRangeChange, which clears batch selection as any navigation does. So selection is lost if selection mode is active at midnight on a calendar that moves range.
  • Paged calendars: cards are remounted by the library's own tick, up to a minute after date-changed, not by this change.

Testing

  • e2e/issues/issue-2504-midnight-bases-views.spec.ts uses the real detector. It failed on the unfixed build at the stale label and passes with the fix, covering List, Kanban, Mini Calendar, a calendar on the old day, a paged calendar, a hidden tab that keeps its DOM until shown, and listener removal on close.
  • New unit tests: basesDateRollover, calendarDateRollover.
  • Adjacent e2e (calendar-engine, calendar-batch, pr-2492): 21 passed.
  • npm test: 782 suites passed, 68 skipped. npm run lint and npm run typecheck pass.

Run with npm locally rather than rpnpm: this repo has no pnpm lockfile, and its GitHub tarball dependency blocks pnpm import.

docs/releases/unreleased.md will need a trivial merge against #2505, which also edits it. No other files overlap.

Bases views never listened for date-changed, so cards kept yesterday's
relative labels and classes until their rows changed. The calendar redraws
its own today marks, but its date stayed on the old day and items placed
relative to now, such as overdue tasks shown on today, did not move.

Views now redraw on a new day through onDataUpdated, which keeps their
mid-drag guards. A calendar on the old day moves to today unless a date is
configured; one paged elsewhere stays put and refreshes its items. Views
with no layout box wait until they are next shown.
@callumalpass
callumalpass merged commit d2d1fb9 into main Nov 5, 2026
3 checks passed
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