@@ -25,6 +25,7 @@ import {
2525 // useMergeCompStyles,
2626} from "lowcoder-sdk" ;
2727import { i18nObjs , trans } from "./i18n/comps" ;
28+ import _ from 'lodash'
2829
2930export enum DEP_TYPE {
3031 CONTRAST_TEXT = 'contrastText' ,
@@ -416,8 +417,8 @@ const filterTaskFields = (task: Task & { barChildren: Omit<OptionPropertyParam,
416417let GanttOption = new MultiCompBuilder (
417418 {
418419 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 ( ) ) ,
421422 label : StringControl ,
422423 id : StringControl ,
423424 project : StringControl ,
@@ -555,6 +556,16 @@ let GanttChartCompBase = (function () {
555556 } ,
556557 } ) ;
557558
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+
558569 useEffect ( ( ) => {
559570 props . ganttTasks . onChange ( updatedGanttTasks ) ;
560571 } , [ updatedGanttTasks ] ) ;
@@ -633,7 +644,7 @@ let GanttChartCompBase = (function () {
633644 < div className = "Wrapper" ref = { conRef } >
634645 { tasks . length > 0 ? (
635646 < Gantt
636- tasks = { tasks }
647+ tasks = { tasks . map ( task => ( { ... task , name : task . title } ) ) }
637648 viewMode = { activeViewMode }
638649 onDateChange = { handleTaskChange }
639650 onDelete = { handleTaskDelete }
0 commit comments