> ## Documentation Index
> Fetch the complete documentation index at: https://learn.nextedy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prevent Tasks from Moving Outside Parent Range

> Configure Nextedy GANTT to enforce date containment constraints so that child tasks cannot be scheduled outside their parent's date range.

export const LastReviewed = ({date}) => {
  if (!date) return null;
  const formatted = new Date(`${date}T00:00:00Z`).toLocaleDateString("en-US", {
    year: "numeric",
    month: "long",
    day: "numeric",
    timeZone: "UTC"
  });
  return <p className="mt-10 text-sm text-gray-400 dark:text-zinc-500 not-prose">
      Last reviewed on {formatted}
    </p>;
};

## How the Constraint Works

When enabled, the Gantt chart enforces that every child task must stay within the date boundaries of its parent task. This applies to three editing interactions:

* **Drag** -- moving a child task bar left or right on the chart
* **Resize** -- extending or shrinking a child task bar from either end
* **Lightbox editing** -- changing dates or duration in the lightbox

If a child task is dragged or resized beyond the parent's boundaries, the Gantt blocks the operation. When editing via the lightbox, validation prevents saving dates that fall outside the parent range.

<Steps>
  <Step title="Enable Range Conflict Detection">
    Add the following to **Widget Properties > Advanced > Gantt Config Script** to enable conflict detection:

    ```javascript theme={null}
    gantt.config.rangeConflict = {
      enabled: true,
      checkStart: true,
      checkEnd: true,
      highlightChild: true
    };
    ```

    | Property         | Description                                                      |
    | ---------------- | ---------------------------------------------------------------- |
    | `enabled`        | Activates parent-child date range conflict detection             |
    | `checkStart`     | Validates that child start dates are not before the parent start |
    | `checkEnd`       | Validates that child end dates are not after the parent end      |
    | `highlightChild` | Highlights out-of-range child tasks with a visual warning style  |

    <Tip title="Check only one boundary">
      If you only need to enforce that children do not extend past the parent's end date (but allow earlier starts), set `checkStart: false` and `checkEnd: true`.
    </Tip>
  </Step>

  <Step title="Understand the Conflict Behavior">
    When range conflict detection is active, the Gantt provides several automatic behaviors:

    **During drag operations:**

    * Child tasks that are dragged outside the parent range are visually highlighted with a conflict indicator
    * When you move the child back within range, the conflict indicator is removed automatically
    * Parent tasks that have out-of-range children are also highlighted

    **During lightbox editing:**

    * If you set a duration or date that places the task outside its parent's bounds, an error message appears and the save button is disabled
    * The error message identifies the parent's date range so you can correct the values

    **Parent resize behavior:**

    * When a parent task is resized and its boundary moves inward, children that would fall outside the new range are automatically adjusted to stay within bounds

    <Warning title="Conflict detection is hierarchical">
      Range conflict checking operates across all ancestor levels, not just the immediate parent. A deeply nested task is validated against every ancestor in the hierarchy. If a grandchild task extends beyond a grandparent's range, both the parent and grandparent are flagged.
    </Warning>
  </Step>

  <Step title="Resolve Existing Conflicts">
    After enabling range conflict detection, the Gantt scans all tasks on load. Parent tasks with out-of-range children are highlighted immediately, so you can identify and fix scheduling inconsistencies in your existing data.

    The conflict tooltip on affected parent tasks displays a message indicating that children have a range conflict.

    <Tip title="Removing the parent clears constraints">
      If a task needs to move freely outside its current parent's range, you can change the parent field to "no parent" in the lightbox. This removes the containment constraint for that task.
    </Tip>
  </Step>

  <Step title="Combine with Drag Children Toggle">
    The Gantt toolbar includes a toggle for dragging children together with their parent. When this toggle is active and you move a parent task, all children move with it, maintaining their relative positions and avoiding range conflicts.

    Use this in combination with range conflict detection to ensure hierarchical consistency during bulk rescheduling.
  </Step>
</Steps>

## Verification

You should now see:

* Child tasks blocked from being dragged past their parent's start or end date
* A visual highlight on parent and child tasks when a range conflict exists
* Error messages in the lightbox when attempting to save dates outside the parent range
* Conflicts detected automatically when the Gantt chart loads

## See Also

* [Derive Parent Schedule from Children](/gantt/guides/scheduling/parent-derived-schedule)
* [Configure Auto-Scheduling](/gantt/guides/scheduling/configure-auto-scheduling)
* [Configure Drag Children Behavior](/gantt/guides/editing/drag-children)
* [Use the Lightbox Inline Editor](/gantt/guides/editing/lightbox-editor)

<LastReviewed date="2026-07-02" />
