gantt-lib 0.88.2 → 0.89.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -9507,6 +9507,7 @@ function TaskGanttChartInner(props, ref) {
9507
9507
  const containerRef = useRef9(null);
9508
9508
  const scrollContainerRef = useRef9(null);
9509
9509
  const scrollContentRef = useRef9(null);
9510
+ const clearSelectedTaskTimeoutRef = useRef9(null);
9510
9511
  const [selectedTaskId, setSelectedTaskId] = useState9(null);
9511
9512
  const [taskListHasRightShadow, setTaskListHasRightShadow] = useState9(false);
9512
9513
  const [selectedChip, setSelectedChip] = useState9(null);
@@ -9626,7 +9627,7 @@ function TaskGanttChartInner(props, ref) {
9626
9627
  const scrollLeft = Math.round(taskOffset - dayWidth * 2);
9627
9628
  container.scrollTo({ left: Math.max(0, scrollLeft), behavior: "smooth" });
9628
9629
  }, [tasks, dateRange, dayWidth]);
9629
- const scrollToRow = useCallback8((taskId) => {
9630
+ const scrollToRow = useCallback8((taskId, options = {}) => {
9630
9631
  const container = scrollContainerRef.current;
9631
9632
  if (!container) return;
9632
9633
  const task = tasks.find((t) => t.id === taskId);
@@ -9635,8 +9636,25 @@ function TaskGanttChartInner(props, ref) {
9635
9636
  if (rowIndex === -1) return;
9636
9637
  const paddedRowIndex = Math.max(0, rowIndex - SCROLL_TO_ROW_CONTEXT_ROWS);
9637
9638
  const scrollTop = Math.max(0, rowHeight * paddedRowIndex);
9638
- setSelectedTaskId(taskId);
9639
- container.scrollTo({ top: scrollTop, behavior: "smooth" });
9639
+ const {
9640
+ select = true,
9641
+ behavior = "smooth",
9642
+ clearSelectionAfterMs
9643
+ } = options;
9644
+ if (clearSelectedTaskTimeoutRef.current !== null) {
9645
+ window.clearTimeout(clearSelectedTaskTimeoutRef.current);
9646
+ clearSelectedTaskTimeoutRef.current = null;
9647
+ }
9648
+ if (select) {
9649
+ setSelectedTaskId(taskId);
9650
+ if (typeof clearSelectionAfterMs === "number" && clearSelectionAfterMs >= 0) {
9651
+ clearSelectedTaskTimeoutRef.current = window.setTimeout(() => {
9652
+ setSelectedTaskId((current) => current === taskId ? null : current);
9653
+ clearSelectedTaskTimeoutRef.current = null;
9654
+ }, clearSelectionAfterMs);
9655
+ }
9656
+ }
9657
+ container.scrollTo({ top: scrollTop, behavior });
9640
9658
  }, [tasks, visibleTasks, rowHeight]);
9641
9659
  const [dragGuideLines, setDragGuideLines] = useState9(null);
9642
9660
  const [draggedTaskOverride, setDraggedTaskOverride] = useState9(null);
@@ -9646,6 +9664,11 @@ function TaskGanttChartInner(props, ref) {
9646
9664
  setValidationResult(result);
9647
9665
  onValidateDependencies?.(result);
9648
9666
  }, [tasks, onValidateDependencies]);
9667
+ useEffect9(() => () => {
9668
+ if (clearSelectedTaskTimeoutRef.current !== null) {
9669
+ window.clearTimeout(clearSelectedTaskTimeoutRef.current);
9670
+ }
9671
+ }, []);
9649
9672
  const handleTaskChange = useCallback8((updatedTasks) => {
9650
9673
  const updatedTask = updatedTasks[0];
9651
9674
  if (!updatedTask) return;