From 72d7414b9851bcc3d415605ce421c0572278a900 Mon Sep 17 00:00:00 2001
From: aaravkumar <aarav.kumar1510@gmail.com>
Date: Wed, 30 Apr 2025 21:38:29 -0400
Subject: fixed error where all day reset would move task node to 1 day before
 actuall all day date in calendar view

---
 src/client/views/nodes/TaskManagerTask.tsx | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

(limited to 'src/client/views/nodes/TaskManagerTask.tsx')

diff --git a/src/client/views/nodes/TaskManagerTask.tsx b/src/client/views/nodes/TaskManagerTask.tsx
index d8c1430d4..913c46bfb 100644
--- a/src/client/views/nodes/TaskManagerTask.tsx
+++ b/src/client/views/nodes/TaskManagerTask.tsx
@@ -14,7 +14,7 @@ interface TaskManagerProps {
 }
 
 @observer
-export class TaskManagerTask extends React.Component<Props> {
+export class TaskManagerTask extends React.Component<TaskManagerProps> {
     public static LayoutString(fieldStr: string) {
         return FieldView.LayoutString(TaskManagerTask, fieldStr);
     }
@@ -89,18 +89,12 @@ export class TaskManagerTask extends React.Component<Props> {
         const doc = this.props.Document;
 
         if (doc.allDay) {
-            // All-day task → use date only
-            if (!doc.title) return;
-
-            const parsedDate = new Date(doc.title as string);
-            if (!isNaN(parsedDate.getTime())) {
-                const localStart = new Date(parsedDate.getFullYear(), parsedDate.getMonth(), parsedDate.getDate());
-                const localEnd = new Date(localStart);
-                doc.date_range = `${localStart.toISOString()}|${localEnd.toISOString()}`;
-                doc.allDay = true;
-            }
+            const range = typeof doc.date_range === 'string' ? doc.date_range.split('|') : [];
+            const dateStr = range[0] ?? new Date().toISOString().split('T')[0]; // default to today
+
+            doc.date_range = `${dateStr}|${dateStr}`;
+            doc.allDay = true;
         } else {
-            // Timed task → use full startTime and endTime
             const startField = doc.startTime;
             const endField = doc.endTime;
             const startDate = startField instanceof DateField ? startField.date : null;
@@ -109,12 +103,13 @@ export class TaskManagerTask extends React.Component<Props> {
             if (startDate && endDate && !isNaN(startDate.getTime()) && !isNaN(endDate.getTime())) {
                 doc.date_range = `${startDate.toISOString()}|${endDate.toISOString()}`;
                 doc.allDay = false;
-            } else {
-                console.warn('startTime or endTime is invalid');
             }
         }
     }
 
+
+
+
     @action
     toggleComplete = (e: React.ChangeEvent<HTMLInputElement>) => {
         this.props.Document.completed = e.target.checked;
@@ -238,8 +233,10 @@ export class TaskManagerTask extends React.Component<Props> {
                             onChange={e => {
                                 const newDate = new Date(e.target.value);
                                 if (!isNaN(newDate.getTime())) {
-                                    const iso = newDate.toISOString().split('T')[0];
-                                    doc.date_range = `${iso}T00:00:00.000Z|${iso}T00:00:00.000Z`;
+                                    const dateStr = e.target.value;
+                                    if (dateStr) {
+                                        doc.date_range = `${dateStr}T00:00:00|${dateStr}T00:00:00`;
+                                    }
                                 }
                             }}
                             disabled={isCompleted}
-- 
cgit v1.2.3-70-g09d2

