Repository navigation
fix(bases): follow the date across midnight in open views (#2504) - #2506
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #2504
Problem
Nothing in
src/baseslistens fordate-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.due: Nov 6 17:25with--futureat +64s, same DOM nodes. Any render fixes it (Today at 17:25)@tasknotes/calendarrebuilds itself on its minute tick when the day changes, sois-todaymoved and cards remounted without TaskNotesNot in the issue: with
showOverdueOnToday, a task that had just become overdue stayed on the old day, because items are projected fromnowand only a refetch moves them.Fix
registerBasesDateRolloverowns the listener. It redraws a view that has a layout box. A view without one (for example a background tab) waits on a one-shotResizeObserveruntil it is shown, then catches up once however many days passed.BasesViewBaseredraws throughonDataUpdated, so Kanban and Task List keep their mid-drag guards. Task List needed no card changes becausebuildCardRenderSignaturealready includestargetDate. This also covers Mini Calendar.CalendarViewoverrides the hook, since itsonDataUpdateddeliberately 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.onDataUpdateditself is unchanged.today()are out of scope.Please check
initialDateorinitialDatePropertyset 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.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.date-changed, not by this change.Testing
e2e/issues/issue-2504-midnight-bases-views.spec.tsuses 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.basesDateRollover,calendarDateRollover.calendar-engine,calendar-batch,pr-2492): 21 passed.npm test: 782 suites passed, 68 skipped.npm run lintandnpm run typecheckpass.Run with npm locally rather than
rpnpm: this repo has no pnpm lockfile, and its GitHub tarball dependency blockspnpm import.docs/releases/unreleased.mdwill need a trivial merge against #2505, which also edits it. No other files overlap.