Skip to content

Commit 7dcefe6

Browse files
committed
#3845 Fix off-by-one start drag bug
1 parent 6b5ab4b commit 7dcefe6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/frontend/src/pages/GanttPage/GanttChart/GanttChartComponents/GanttTaskBar/GanttTaskBarEditView.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ export const GanttTaskBarEditView = <T,>({
9191
return Math.floor(num / 7) * 7;
9292
};
9393

94+
const ceilToMultipleOf7 = (num: number) => {
95+
return Math.ceil(num / 7) * 7;
96+
};
97+
9498
const getDistanceFromLeft = (clientX: number) => {
9599
if (!boxRef.current) return 0;
96100
const rect = boxRef.current.getBoundingClientRect();
@@ -142,7 +146,7 @@ export const GanttTaskBarEditView = <T,>({
142146
e.preventDefault();
143147
};
144148
const onDrop = (day: Date) => {
145-
const days = floorToMultipleOf7(differenceInDays(day, task.start));
149+
const days = ceilToMultipleOf7(differenceInDays(day, task.start));
146150
createChange({ id: uuidv4(), element: task.element, type: 'shift-by-days', days });
147151
};
148152

0 commit comments

Comments
 (0)