diff --git a/src/components/GridTaskBlock.tsx b/src/components/GridTaskBlock.tsx index 42f116c..f459a56 100644 --- a/src/components/GridTaskBlock.tsx +++ b/src/components/GridTaskBlock.tsx @@ -111,16 +111,18 @@ export function GridTaskBlock({ const pixelsPerMinute = getSlotHeight(cellDuration) / cellDuration; useEffect(() => { - const onResizeMove = (e: MouseEvent) => { + if (!task.startTime) return; + + const handleResizeMove = (e: MouseEvent) => { if (!isResizing) return; const deltaY = e.clientY - resizeStartY.current; let newHeight = resizeStartHeight.current + deltaY; - const minHeight = 15 * pixelsPerMinute; // min 15 mins + const minHeight = 15 * pixelsPerMinute; if (newHeight < minHeight) newHeight = minHeight; setResizeHeight(newHeight); }; - const onResizeEnd = () => { + const handleResizeEnd = () => { if (!isResizing) return; setIsResizing(false); document.body.style.cursor = ""; @@ -132,15 +134,15 @@ export function GridTaskBlock({ }; if (isResizing) { - window.addEventListener("mousemove", onResizeMove); - window.addEventListener("mouseup", onResizeEnd); + window.addEventListener("mousemove", handleResizeMove); + window.addEventListener("mouseup", handleResizeEnd); } return () => { - window.removeEventListener("mousemove", onResizeMove); - window.removeEventListener("mouseup", onResizeEnd); + window.removeEventListener("mousemove", handleResizeMove); + window.removeEventListener("mouseup", handleResizeEnd); }; - }, [isResizing, resizeHeight, pixelsPerMinute, task.id, updateTaskDuration]); + }, [isResizing, resizeHeight, pixelsPerMinute, task.id, updateTaskDuration, task.startTime]); if (!task.startTime) return null;