diff --git a/package.json b/package.json index b51efc5..7f64d1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "my-weekly-todo-list", - "version": "1.33.2", + "version": "1.33.3", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view", "main": "index.js", "scripts": { diff --git a/src/components/GridTaskBlock.tsx b/src/components/GridTaskBlock.tsx index 6e899db..adc4878 100644 --- a/src/components/GridTaskBlock.tsx +++ b/src/components/GridTaskBlock.tsx @@ -171,7 +171,7 @@ export function GridTaskBlock({ if (!task.startTime) return null; const [startHour, startMinute] = task.startTime.split(":").map(Number); - const startMinutes = (startHour - workingHoursStart) * 60 + startMinute; + const startMinutes = startHour * 60 + startMinute; const topOffset = startMinutes * pixelsPerMinute; const duration = task.duration || 15; const baseHeight = duration * pixelsPerMinute; diff --git a/src/components/WeeklyView.tsx b/src/components/WeeklyView.tsx index e5c48b3..00ad5f6 100644 --- a/src/components/WeeklyView.tsx +++ b/src/components/WeeklyView.tsx @@ -2579,37 +2579,36 @@ export default function WeeklyView() { } }, [currentWeekStart, session, fetchCalendarEvents]); - // Initial scroll to preferred start hour + // Scroll to preferred start hour (initial load + when user changes startHour) useEffect(() => { if (!isLoading) { const performScroll = () => { const slotsPerHour = 60 / cellDuration; const slotHeight = getSlotHeight(cellDuration); const scrollOffset = workingHoursStart * slotsPerHour * slotHeight; - - console.log(`[SCROLL] Initial scroll to startHour ${workingHoursStart} (offset ${scrollOffset}px)`); - + // Force it directly if (gridRef.current) gridRef.current.scrollTop = scrollOffset; if (timeColumnRef.current) timeColumnRef.current.scrollTop = scrollOffset; - + intendedScrollTop.current = scrollOffset; - // Repeatedly re-enforce for 2 seconds to fight browser auto-scroll restoration - const interval = setInterval(() => { - if (gridRef.current) gridRef.current.scrollTop = scrollOffset; - if (timeColumnRef.current) timeColumnRef.current.scrollTop = scrollOffset; - }, 50); + // On initial load, re-enforce for 2s to fight browser auto-scroll restoration + if (!isInitialScrollDone.current) { + const interval = setInterval(() => { + if (gridRef.current) gridRef.current.scrollTop = scrollOffset; + if (timeColumnRef.current) timeColumnRef.current.scrollTop = scrollOffset; + }, 50); - setTimeout(() => { - clearInterval(interval); - isInitialScrollDone.current = true; - console.log(`[SCROLL] Stabilization period done. Grid scroll: ${gridRef.current?.scrollTop}`); - }, 2000); + setTimeout(() => { + clearInterval(interval); + isInitialScrollDone.current = true; + }, 2000); + } }; // Delay slightly to ensure layout is stable - const timer = setTimeout(performScroll, 500); + const timer = setTimeout(performScroll, isInitialScrollDone.current ? 50 : 500); return () => clearTimeout(timer); } }, [isLoading, workingHoursStart, cellDuration]);