@@ -96,11 +96,16 @@ const CardTemplate = React.memo((props: {
9696 tagStyles : Record < string , string > ;
9797} ) => {
9898 const editorState = useContext ( EditorContext ) ;
99- if ( editorState ) {
100- return props . cardView . cardViewConfig . cardTemplate (
99+
100+ const template = useMemo ( ( ) => {
101+ return props . cardView . cardTemplate (
101102 props . data ,
102103 props . cardIndex ,
103- ) ;
104+ )
105+ } , [ JSON . stringify ( props . data ) , props . cardIndex ] ) ;
106+
107+ if ( editorState ) {
108+ return template ;
104109 }
105110
106111 return (
@@ -167,12 +172,10 @@ type Props = {
167172
168173export const KanbanCompView = React . memo ( ( props : Props ) => {
169174 const { comp } = props ;
170-
171175 // const childrenProps = useMemo(() =>
172176 // childrenToProps(comp.children),
173177 // [childrenToProps, comp.children],
174178 // );
175-
176179 const childrenProps = childrenToProps ( comp . children ) ;
177180
178181 const [ dataMap , setDataMap ] = useState < Record < string , number > > ( { } ) ;
@@ -182,7 +185,7 @@ export const KanbanCompView = React.memo((props: Props) => {
182185 const updateDataMap = useCallback ( ( ) => {
183186 const mapData : Record < string , number > = { } ;
184187 childrenProps . data ?. forEach ( ( item : any , index : number ) => {
185- mapData [ item . Id ] = index ;
188+ mapData [ item . id ] = index ;
186189 } )
187190 setDataMap ( mapData ) ;
188191 } , [ setDataMap ] ) ;
@@ -195,13 +198,13 @@ export const KanbanCompView = React.memo((props: Props) => {
195198 updateDataMap ( ) ;
196199 } , [ JSON . stringify ( childrenProps . data ) , updateDataMap ] ) ;
197200
198- let data : Object [ ] = useMemo ( ( ) => extend (
201+ const kanbanData : Object [ ] = useMemo ( ( ) => extend (
199202 [ ] ,
200203 childrenProps . data as { [ key : string ] : Object } ,
201204 undefined ,
202205 true
203206 ) as Object [ ]
204- , [ childrenProps . data ]
207+ , [ JSON . stringify ( childrenProps . data ) ]
205208 ) ;
206209
207210 const showModal = useCallback ( ( ) => {
@@ -233,7 +236,7 @@ export const KanbanCompView = React.memo((props: Props) => {
233236 }
234237 } ) ;
235238 return assignees ;
236- } , [ childrenProps . assigneeOptions ] ) ;
239+ } , [ JSON . stringify ( childrenProps . assigneeOptions ) ] ) ;
237240
238241 const statusOptions = useMemo ( ( ) => {
239242 let uniqueObjectsArray : any = [ ] ;
@@ -251,7 +254,7 @@ export const KanbanCompView = React.memo((props: Props) => {
251254 }
252255 } ) ;
253256 return uniqueObjectsArray ;
254- } , [ childrenProps . statusOptions ] ) ;
257+ } , [ JSON . stringify ( childrenProps . statusOptions ) ] ) ;
255258
256259 const handleDataChange = ( kanbanData : Array < Record < string , any > > ) => {
257260 comp . children ?. data . children . manual . children . manual . dispatch (
@@ -271,7 +274,7 @@ export const KanbanCompView = React.memo((props: Props) => {
271274 } : {
272275 changedRecords : Array < Record < string , any > >
273276 } ) => {
274- const updatedData = [ ...data ] as Array < Record < string , any > > ;
277+ const updatedData = [ ...kanbanData ] as Array < Record < string , any > > ;
275278 changedRecords . forEach ( ( record ) => {
276279 const { id } = record ;
277280 const index = updatedData . findIndex ( ( item : any ) => item . id === id ) ;
@@ -284,7 +287,7 @@ export const KanbanCompView = React.memo((props: Props) => {
284287
285288 const handleOk = ( dialogData : Record < string , string > ) => {
286289 const { id } = dialogData ;
287- const updatedData = [ ...data ] ;
290+ const updatedData = [ ...kanbanData ] ;
288291 const index = updatedData . findIndex ( ( item : any ) => item . id === id ) ;
289292 if ( index > - 1 ) {
290293 updatedData [ index ] = dialogData ;
@@ -303,7 +306,7 @@ export const KanbanCompView = React.memo((props: Props) => {
303306 const cardIndex = dataMap [ data . id ] || 0 ;
304307 return (
305308 < CardTemplate
306- data = { data }
309+ data = { { ... data } }
307310 cardIndex = { cardIndex }
308311 cardView = { childrenProps . cardView }
309312 cardHeaderStyles = { childrenProps . cardHeaderStyles }
@@ -343,7 +346,7 @@ export const KanbanCompView = React.memo((props: Props) => {
343346 id = "kanban"
344347 cssClass = "kanban-overview"
345348 keyField = "status"
346- dataSource = { data }
349+ dataSource = { [ ... kanbanData ] }
347350 cardDoubleClick = { OnCardDoubleClick }
348351 cardClick = { ( args : CardClickEventArgs ) => args . event ?. stopPropagation ( ) }
349352 swimlaneSettings = { { keyField : 'assignee' } }
@@ -373,7 +376,7 @@ export const KanbanCompView = React.memo((props: Props) => {
373376 </ LayoutContainer >
374377 </ ScrollBar >
375378 < SlotConfigContext . Provider value = { { modalWidth : 600 } } >
376- { childrenProps . cardView . expandModalView }
379+ { childrenProps . cardView . cardModalView }
377380 </ SlotConfigContext . Provider >
378381 </ div >
379382 </ div >
0 commit comments