MaTeMaTuK / gantt-task-react

Gantt chart for React with Typescript
MIT License
847 stars 471 forks source link

Uncaught RangeError: Invalid array length at Array.concat (<anonymous>) #79

Open jasonusdid opened 2 years ago

jasonusdid commented 2 years ago

Hi,

I created a project task with many sub project/task, but when collaps the top project, it failed and showed below error. Please help to check. Thanks.

image

image

maberalc commented 2 years ago

Solved it changing in file other-helper.ts in method getChildren, this:

var taskChildren = tasks.reduce(function (children, t) { return children.concat(children, getChildren(taskList, t)); }, []);

For this:

var taskChildren: Task[] = []; tasks.forEach(t => { taskChildren.push(...getChildren(taskList, t)); })

I have not fully tested this solution, but I guess it's doing the same.

jasonusdid commented 2 years ago

Thanks for the quick fix. How can I integrate the fix in my project please? I have updated the package, it's still v0.3.8... and tested the function it still error out with the same reason.

Thanks.

maberalc commented 2 years ago

You have to build this package, then I had to delete node_modules (I was using create-react-app to test this library) and reinstall everything. Then change the new build in /node_modules/gantt-task-react/dist directory with the files in dist folder (created after build). Then when you use npm start, it should be okay.

lems3 commented 5 months ago

@jasonusdid I'm trying to change the columns in our Gantt, and add margin to the left on childtasks, as you did. How did you achieve it ?