fix: resolve React Hook violation in GridTaskBlock
This commit is contained in:
parent
dddde43935
commit
9652bd374e
@ -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;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user