Skip to content

Commit

Permalink
[Demo]: fixed project table demo "Add task" action
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseyManetov committed Nov 18, 2024
1 parent f7fe841 commit fbf6342
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/src/demo/tables/editableTable/ProjectTableDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function ProjectTableDemo() {
}, []);

const insertTask = useCallback((position: DropPosition, relativeTask: Task | null = null, existingTask: Task | null = null) => {
const taskToInsert: Task = existingTask ? { ...existingTask, type: 'task' } : { id: lastId--, name: '', type: 'task' };
const taskToInsert: Task = existingTask ? { ...existingTask, type: 'task' } : { id: lastId--, name: '', type: 'task', parentId: null };
const task: Task = setTaskInsertPosition(taskToInsert, relativeTask, position, treeRef.current);

setValue((currentValue) => {
Expand All @@ -153,9 +153,11 @@ export function ProjectTableDemo() {
}
}

let currentItems = currentValue.items
.set(task.id, task)
.set(parentTask.id, parentTask);
let currentItems = currentValue.items.set(task.id, task);

if (parentTask) {
currentValue.items.set(parentTask.id, parentTask);
}

if (prevParentTask !== null && prevParentTask !== NOT_FOUND_RECORD) {
currentItems = currentItems.set(prevParentTask.id, prevParentTask);
Expand Down

0 comments on commit fbf6342

Please sign in to comment.