File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,13 @@ export const CheckRow = (rowId: string) => (state) => {
13
13
} ;
14
14
15
15
export const UncheckRow = ( rowId : string ) => ( state ) => {
16
- const index = state . rowSelection . rowIds . indexOf ( rowId ) ;
16
+ const rowIds = state . rowSelection ?. rowIds || [ ] ;
17
+ const index = rowIds . indexOf ( rowId ) ;
17
18
18
19
// rowId doesn't exist
19
- if ( index === - 1 ) state ;
20
+ if ( index === - 1 ) return state ;
20
21
21
- const cloned = [ ...state . rowSelection . rowIds ] ;
22
+ const cloned = [ ...rowIds ] ;
22
23
cloned . splice ( index , 1 ) ;
23
24
24
25
return {
Original file line number Diff line number Diff line change @@ -39,6 +39,26 @@ describe('Actions', () => {
39
39
} ) ;
40
40
} ) ;
41
41
42
+ it ( 'should UNCHECK the correct item' , ( ) => {
43
+ const state = Actions . UncheckRow ( '42' ) ( {
44
+ rowSelection : {
45
+ rowIds : [ '22' , '11' ] ,
46
+ } ,
47
+ } ) ;
48
+
49
+ expect ( state ) . toStrictEqual ( {
50
+ rowSelection : {
51
+ rowIds : [ '22' , '11' ] ,
52
+ } ,
53
+ } ) ;
54
+ } ) ;
55
+
56
+ it ( 'should UNCHECK when rowIds is null' , ( ) => {
57
+ const state = Actions . UncheckRow ( '42' ) ( { } ) ;
58
+
59
+ expect ( state ) . toStrictEqual ( { } ) ;
60
+ } ) ;
61
+
42
62
it ( 'should trigger UNCHECK when rowIds is empty' , ( ) => {
43
63
const state = Actions . UncheckRow ( '42' ) ( {
44
64
rowSelection : {
You can’t perform that action at this time.
0 commit comments