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:
parent
ebfe911b81
commit
ee2f7bfb69
@ -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": {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -2579,7 +2579,7 @@ 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 = () => {
|
||||
@ -2587,29 +2587,28 @@ export default function WeeklyView() {
|
||||
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]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user