@@ -25,6 +25,7 @@ import {
25
25
// useMergeCompStyles,
26
26
} from "lowcoder-sdk" ;
27
27
import { i18nObjs , trans } from "./i18n/comps" ;
28
+ import _ from 'lodash'
28
29
29
30
export enum DEP_TYPE {
30
31
CONTRAST_TEXT = 'contrastText' ,
@@ -416,8 +417,8 @@ const filterTaskFields = (task: Task & { barChildren: Omit<OptionPropertyParam,
416
417
let GanttOption = new MultiCompBuilder (
417
418
{
418
419
title : StringControl ,
419
- start : jsonControl ( ( data : any ) => new Date ( data ) ) ,
420
- end : jsonControl ( ( data : any ) => new Date ( data ) ) ,
420
+ start : jsonControl ( ( data : any ) => data ? new Date ( data ) : new Date ( ) ) ,
421
+ end : jsonControl ( ( data : any ) => data ? new Date ( data ) : new Date ( ) ) ,
421
422
label : StringControl ,
422
423
id : StringControl ,
423
424
project : StringControl ,
@@ -555,6 +556,16 @@ let GanttChartCompBase = (function () {
555
556
} ,
556
557
} ) ;
557
558
559
+ useEffect ( ( ) => {
560
+ if ( tasks . length === 0 ) {
561
+ if ( props . data . length > 0 ) {
562
+ setTasks ( props . data ) ;
563
+ }
564
+ } else if ( ! _ . isEqual ( props . data , tasks ) ) {
565
+ setTasks ( props . data )
566
+ }
567
+ } , [ props . data ] )
568
+
558
569
useEffect ( ( ) => {
559
570
props . ganttTasks . onChange ( updatedGanttTasks ) ;
560
571
} , [ updatedGanttTasks ] ) ;
@@ -633,7 +644,7 @@ let GanttChartCompBase = (function () {
633
644
< div className = "Wrapper" ref = { conRef } >
634
645
{ tasks . length > 0 ? (
635
646
< Gantt
636
- tasks = { tasks }
647
+ tasks = { tasks . map ( task => ( { ... task , name : task . title } ) ) }
637
648
viewMode = { activeViewMode }
638
649
onDateChange = { handleTaskChange }
639
650
onDelete = { handleTaskDelete }
0 commit comments