@@ -9,12 +9,14 @@ import {
9
9
withMethodExposing ,
10
10
CompAction ,
11
11
CompDepsConfig ,
12
+ CompActionTypes ,
12
13
} from 'lowcoder-sdk' ;
13
14
import { trans } from "./i18n/comps" ;
14
15
import { KanbanInitComp } from './kanbanTypes' ;
15
16
import { KanbanPropertyView } from './kanbanPropertyView' ;
16
17
import { KanbanCompView } from './kanbanCompView' ;
17
18
import * as datasource from './datasource.json' ;
19
+ import isEqual from 'lodash.isequal' ;
18
20
19
21
type IContainer = typeof IContainer ;
20
22
type NameGenerator = typeof NameGenerator ;
@@ -50,20 +52,39 @@ export class KanbanImplComp extends KanbanInitComp implements IContainer {
50
52
51
53
override reduce ( action : CompAction ) : this {
52
54
let comp = super . reduce ( action ) ;
53
- const params = comp . children . cardView . children . cardView . getCachedParams ( '0' ) ;
54
- if ( ! Boolean ( params ) ) {
55
+
56
+ let dataChanged = false ;
57
+ if ( action . type === CompActionTypes . UPDATE_NODES_V2 ) {
58
+ dataChanged =
59
+ comp . children . data !== this . children . data &&
60
+ isEqual ( this . children . data . getView ( ) , comp . children . data . getView ( ) ) ;
61
+ }
62
+
63
+ const thisSelection = this . children . activeCardIndex . getView ( ) ?? "0" ;
64
+ const newSelection = comp . children . activeCardIndex . getView ( ) ?? "0" ;
65
+ const selectionChanged = thisSelection !== newSelection ;
66
+ let params = comp . children . cardView . children . cardView . getCachedParams ( newSelection ) ;
67
+ if ( selectionChanged || ! Boolean ( params ) || dataChanged ) {
68
+ params = ! Boolean ( params ) || dataChanged
69
+ ? {
70
+ currentRow : comp . children . data . getView ( ) [ newSelection ] ,
71
+ currentIndex : newSelection ,
72
+ currentOriginalIndex : newSelection ,
73
+ } : undefined ;
55
74
comp = comp . setChild (
56
75
"cardView" ,
57
76
comp . children . cardView . reduce (
58
- comp . children . cardView . setSelectionAction ( '0' , params )
77
+ comp . children . cardView . setSelectionAction ( newSelection , params )
59
78
)
60
79
) ;
61
80
}
62
81
return comp ;
63
82
}
64
83
}
65
84
66
- const KanbanRenderComp = withViewFn ( KanbanImplComp , ( comp : KanbanImplComp ) => < KanbanCompView comp = { comp } /> ) ;
85
+ const KanbanRenderComp = withViewFn ( KanbanImplComp , ( comp : KanbanImplComp ) => {
86
+ return < KanbanCompView comp = { comp } />
87
+ } ) ;
67
88
let KanbanPropertyComp = withPropertyViewFn ( KanbanRenderComp , ( comp : KanbanImplComp ) => {
68
89
return < KanbanPropertyView comp = { comp } /> ;
69
90
} ) ;
0 commit comments