Fix a bug about resetting the calendar view to today incorrectly

This commit is contained in:
Lorite 2026-03-08 16:40:34 +01:00 committed by callumalpass
parent b186b240b8
commit c3d69d33f6
2 changed files with 8 additions and 1 deletions

View file

@ -36,6 +36,9 @@ Example:
- (#1644) Fixed generated default task views so recurring tasks without a `complete_instances` property are still treated as incomplete and appear in views like This Week, Today, and Overdue
- Thanks to @bkennedy-improving for reporting
- Updated generated `_types/task.md` mdbase schema output so `dateCreated` and `dateModified` include generated values (`now` and `now_on_write`) for automatic timestamp handling on create/write
- (#1513, #1686) Fixed a calendar view issue where creating or modifying events, timeblocks, etc. could reset the visible date back to today
- Preserves the visible date for in-place calendar recreation without overriding explicit initial-date navigation settings
- Thanks to @Lorite for the fix
- Fixed documentation deployment CI failures caused by `docs-builder/src/js/main.js` being excluded by a broad `.gitignore` `main.js` rule
- Added a specific unignore rule so the docs site client script is tracked and available in GitHub Actions builds
- Reduced long-running performance risk from calendar sync token persistence by avoiding full runtime settings side-effects during background sync writes

View file

@ -113,6 +113,8 @@ export class CalendarView extends BasesViewBase {
// Flag to indicate config changed and calendar needs recreation
private _configChangedNeedsRecreate = false;
// Preserve visible date when calendar is re-created.
private _recreateTargetDate: Date | null = null;
private viewOptions: {
// Events
@ -617,6 +619,7 @@ export class CalendarView extends BasesViewBase {
this._configChangedNeedsRecreate = false;
this.readViewOptions();
if (this.calendar) {
this._recreateTargetDate = this.calendar.getDate();
this.calendar.destroy();
this.calendar = null;
}
@ -675,7 +678,7 @@ export class CalendarView extends BasesViewBase {
if (!this.calendarEl) return;
// Determine initial date
const initialDate = this.determineInitialDate(taskNotes);
const initialDate = this._recreateTargetDate ?? this.determineInitialDate(taskNotes);
// Build calendar options
const calendarOptions: CalendarOptions = {
@ -822,6 +825,7 @@ export class CalendarView extends BasesViewBase {
// Create calendar
this.calendar = new Calendar(this.calendarEl, calendarOptions);
this.calendar.render();
this._recreateTargetDate = null;
// Apply showTodayHighlight option via CSS
this.applyTodayHighlightStyling();