# Locked Tasks
URL: https://pro.rv-grid.com/guides/gantt/features/locked-tasks/
Source: src/content/docs/guides/gantt/features/locked-tasks.mdx
Description: Use task-level locking to block packaged Gantt task mutations for protected tasks.
Locked tasks let an application protect individual tasks after approval, baseline capture, phase closure, or any other workflow decision. A locked task remains visible in the task table and timeline, but packaged Gantt task mutations are rejected for that task.

Set `locked: true` on the flat task source row:

```ts
const tasks = [
  {
    id: 'design-signoff',
    parentId: null,
    name: 'Design sign-off',
    type: 'milestone',
    status: 'done',
    startDate: '2026-04-15',
    endDate: '2026-04-15',
    duration: 1,
    percentDone: 100,
    calendarId: 'standard',
    tags: ['approved'],
    locked: true,
  },
];
```

## What It Blocks

`locked: true` blocks packaged task mutations for the locked task:

- Timeline task movement and resizing.
- Split creation, movement, and removal.
- Progress updates.
- Inline task-field edits routed through the Gantt task mutation service.
- Indent and outdent actions.
- Child task creation under a locked parent.
- Delete when the selected task subtree contains a locked task.

Blocked task mutations return `readonly-task` and leave task data unchanged.

## What Still Works

Locking a task does not remove it from scheduling, rendering, or inspection flows:

- The task still renders in the table and timeline.
- Scheduler recalculation can still read the task and include it in dependencies, critical path, baselines, and diagnostics.
- Search, filter, sort, expand/collapse, scroll, and zoom remain available.
- Non-locked tasks continue to edit normally.

## Boundaries

The source-row `locked` field is task-level protection, not a complete permission or checkout system.

Dependency changes are not globally disabled by locking a task. Assignment/resource edits are also handled by their own mutation service. Use `gantt.readOnly` when the whole project should reject packaged task, dependency, and assignment mutations.

For application-specific policy, pair locked tasks with cancelable Gantt events or validation recipes.

```ts
grid.addEventListener('gantt-before-task-change', (event) => {
  if (lockedTaskIds.has(event.detail.taskId)) {
    event.preventDefault();
  }
});
```

## Visual Indicators

Use the status indicator helpers when you want to show a lock label, class name, icon, or tooltip in a custom renderer.

```ts
const status = createTaskStatusIndicators({
  taskId: row.id,
  taskLocked: row.locked === true,
});

renderIndicatorCell({
  className: status.classNames.join(' '),
  title: status.label,
  indicators: status.indicators,
});
```

The helper returns metadata only, so the host application can choose the exact icon and placement.

## Context Menu

The built-in Gantt row context menu hides hierarchy actions when the selected task is locked. Mutating row actions are also guarded by the task mutation service, so direct calls still return `readonly-task`.
