fix: tasks stay in correct timeslot when changing visible hours

- GridTaskBlock now positions tasks from hour 0, not from workingHoursStart
- Changing start/end hour only scrolls the view, doesn't shift task positions
- Calendar events and tasks now align on the same time slots

v1.33.3

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
mARTin 2026-03-14 18:46:34 +01:00
parent ebfe911b81
commit ee2f7bfb69
3 changed files with 17 additions and 18 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "my-weekly-todo-list", "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", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -171,7 +171,7 @@ export function GridTaskBlock({
if (!task.startTime) return null; if (!task.startTime) return null;
const [startHour, startMinute] = task.startTime.split(":").map(Number); const [startHour, startMinute] = task.startTime.split(":").map(Number);
const startMinutes = (startHour - workingHoursStart) * 60 + startMinute; const startMinutes = startHour * 60 + startMinute;
const topOffset = startMinutes * pixelsPerMinute; const topOffset = startMinutes * pixelsPerMinute;
const duration = task.duration || 15; const duration = task.duration || 15;
const baseHeight = duration * pixelsPerMinute; const baseHeight = duration * pixelsPerMinute;

View File

@ -2579,7 +2579,7 @@ export default function WeeklyView() {
} }
}, [currentWeekStart, session, fetchCalendarEvents]); }, [currentWeekStart, session, fetchCalendarEvents]);
// Initial scroll to preferred start hour // Scroll to preferred start hour (initial load + when user changes startHour)
useEffect(() => { useEffect(() => {
if (!isLoading) { if (!isLoading) {
const performScroll = () => { const performScroll = () => {
@ -2587,29 +2587,28 @@ export default function WeeklyView() {
const slotHeight = getSlotHeight(cellDuration); const slotHeight = getSlotHeight(cellDuration);
const scrollOffset = workingHoursStart * slotsPerHour * slotHeight; const scrollOffset = workingHoursStart * slotsPerHour * slotHeight;
console.log(`[SCROLL] Initial scroll to startHour ${workingHoursStart} (offset ${scrollOffset}px)`);
// Force it directly // Force it directly
if (gridRef.current) gridRef.current.scrollTop = scrollOffset; if (gridRef.current) gridRef.current.scrollTop = scrollOffset;
if (timeColumnRef.current) timeColumnRef.current.scrollTop = scrollOffset; if (timeColumnRef.current) timeColumnRef.current.scrollTop = scrollOffset;
intendedScrollTop.current = scrollOffset; intendedScrollTop.current = scrollOffset;
// Repeatedly re-enforce for 2 seconds to fight browser auto-scroll restoration // On initial load, re-enforce for 2s to fight browser auto-scroll restoration
const interval = setInterval(() => { if (!isInitialScrollDone.current) {
if (gridRef.current) gridRef.current.scrollTop = scrollOffset; const interval = setInterval(() => {
if (timeColumnRef.current) timeColumnRef.current.scrollTop = scrollOffset; if (gridRef.current) gridRef.current.scrollTop = scrollOffset;
}, 50); if (timeColumnRef.current) timeColumnRef.current.scrollTop = scrollOffset;
}, 50);
setTimeout(() => { setTimeout(() => {
clearInterval(interval); clearInterval(interval);
isInitialScrollDone.current = true; isInitialScrollDone.current = true;
console.log(`[SCROLL] Stabilization period done. Grid scroll: ${gridRef.current?.scrollTop}`); }, 2000);
}, 2000); }
}; };
// Delay slightly to ensure layout is stable // Delay slightly to ensure layout is stable
const timer = setTimeout(performScroll, 500); const timer = setTimeout(performScroll, isInitialScrollDone.current ? 50 : 500);
return () => clearTimeout(timer); return () => clearTimeout(timer);
} }
}, [isLoading, workingHoursStart, cellDuration]); }, [isLoading, workingHoursStart, cellDuration]);