@@ -314,7 +314,6 @@ function setItemsBasedOnGroups(groups: Group[]) {
314314 } ) ;
315315 setItemsBasedOnGroups ( group . children ) ;
316316 } ) ;
317- console . log ( "items" , items ) ;
318317 setItems ( items ) ;
319318}
320319
@@ -1030,7 +1029,7 @@ const checkType = (value: string, type: string | undefined): string => {
10301029 }
10311030 ] ;
10321031
1033- function onUpClick ( index : number , items : IFilterPart [ ] ) {
1032+ function onUpClick ( index : number , items : IFilterPart [ ] ) {
10341033 let newItems = [ ...items ] ;
10351034 const insertIndex = index - 1 ;
10361035 if ( insertIndex < 0 ) { return ; }
@@ -1046,10 +1045,10 @@ const checkType = (value: string, type: string | undefined): string => {
10461045
10471046 setIsDragAndDropEnabled ( true ) ;
10481047 newItems = newItems . filter ( ( _ , i ) => i !== index ) ;
1049- newItems . splice ( insertIndex , 0 , { ...items [ index ] } ) ;
1048+ newItems . splice ( insertIndex , 0 , { ...items [ index ] } ) ;
10501049 let newChildren : ChildType [ ] = newItems . map ( ( item ) => ( {
10511050 filter : `${ item . attribute } ${ item . equalityOperator } ${ item . value } ${ item . andOr } ` ,
1052- } ) ) ;
1051+ } ) ) ;
10531052
10541053 if ( groupingEnabled ) {
10551054 const groupIndex = groups . findIndex ( group =>
@@ -1068,13 +1067,13 @@ const checkType = (value: string, type: string | undefined): string => {
10681067 ) : - 1 ;
10691068
10701069 if ( groupIndex !== - 1 && childIndex === - 1 ) {
1071- groups [ groupIndex ] . items = newItems ;
1070+ groups [ groupIndex ] . items = newItems ;
10721071 setGroups ( groups ) ;
10731072 getGroupLabels ( groups ) ;
10741073 setItemsBasedOnGroups ( groups ) ;
10751074 }
10761075 else if ( groupIndex !== - 1 && childIndex !== - 1 ) {
1077- groups [ groupIndex ] . children [ childIndex ] . items = newItems ;
1076+ groups [ groupIndex ] . children [ childIndex ] . items = newItems ;
10781077 setGroups ( groups ) ;
10791078 getGroupLabels ( groups ) ;
10801079 setItemsBasedOnGroups ( groups ) ;
@@ -1091,7 +1090,11 @@ const checkType = (value: string, type: string | undefined): string => {
10911090 function onDownClick ( index : number , items : IFilterPart [ ] ) {
10921091 let newItems = [ ...items ] ;
10931092 const insertIndex = index + 1 ;
1094- if ( insertIndex > items . length ) { return ; }
1093+
1094+ console . log ( "insertIndex" , insertIndex ) ;
1095+ console . log ( "items.length" , items . length ) ;
1096+
1097+ if ( insertIndex >= items . length ) { return ; }
10951098
10961099 let sourceItems : IFilterPart [ ] = [ ] ;
10971100 sourceItems . push ( items [ index ] ) ;
@@ -1104,7 +1107,7 @@ const checkType = (value: string, type: string | undefined): string => {
11041107
11051108 setIsDragAndDropEnabled ( true ) ;
11061109 newItems = newItems . filter ( ( _ , i ) => i !== index ) ;
1107- newItems . splice ( insertIndex , 0 , { ...items [ index ] } ) ;
1110+ newItems . splice ( insertIndex , 0 , { ...items [ index ] } ) ;
11081111 let newChildren : ChildType [ ] = newItems . map ( ( item ) => ( {
11091112 filter : `${ item . attribute } ${ item . equalityOperator } ${ item . value } ${ item . andOr } ` ,
11101113 } ) ) ;
@@ -1126,13 +1129,13 @@ const checkType = (value: string, type: string | undefined): string => {
11261129 ) : - 1 ;
11271130
11281131 if ( groupIndex !== - 1 && childIndex === - 1 ) {
1129- groups [ groupIndex ] . items = newItems ;
1132+ groups [ groupIndex ] . items = newItems ;
11301133 setGroups ( groups ) ;
11311134 getGroupLabels ( groups ) ;
11321135 setItemsBasedOnGroups ( groups ) ;
11331136 }
11341137 else if ( groupIndex !== - 1 && childIndex !== - 1 ) {
1135- groups [ groupIndex ] . children [ childIndex ] . items = newItems ;
1138+ groups [ groupIndex ] . children [ childIndex ] . items = newItems ;
11361139 setGroups ( groups ) ;
11371140 getGroupLabels ( groups ) ;
11381141 setItemsBasedOnGroups ( groups ) ;
@@ -1147,28 +1150,32 @@ const checkType = (value: string, type: string | undefined): string => {
11471150 }
11481151
11491152
1150- function onGroupUpClick ( index : number ) {
1153+ function onGroupUpClick ( index : number ) {
11511154 let newGroups = [ ...groups ] ;
11521155 const insertIndex = index - 1 ;
11531156 if ( insertIndex < 0 ) { return ; }
11541157
11551158 setIsDragAndDropEnabled ( true ) ;
11561159 newGroups = newGroups . filter ( ( _ , i ) => i !== index ) ;
1157- newGroups . splice ( insertIndex , 0 , { ...groups [ index ] } ) ;
1160+ newGroups . splice ( insertIndex , 0 , { ...groups [ index ] } ) ;
11581161
11591162 setGroups ( newGroups ) ;
1163+ getGroupLabels ( newGroups ) ;
1164+ setItemsBasedOnGroups ( newGroups ) ;
11601165 }
11611166
1162- function onGroupDownClick ( index : number ) {
1167+ function onGroupDownClick ( index : number ) {
11631168 let newGroups = [ ...groups ] ;
11641169 const insertIndex = index + 1 ;
11651170 if ( insertIndex > groups . length ) { return ; }
11661171
11671172 setIsDragAndDropEnabled ( true ) ;
11681173 newGroups = newGroups . filter ( ( _ , i ) => i !== index ) ;
1169- newGroups . splice ( insertIndex , 0 , { ...groups [ index ] } ) ;
1174+ newGroups . splice ( insertIndex , 0 , { ...groups [ index ] } ) ;
11701175
11711176 setGroups ( newGroups ) ;
1177+ getGroupLabels ( newGroups ) ;
1178+ setItemsBasedOnGroups ( newGroups ) ;
11721179 }
11731180
11741181 const onRenderItemColumn = ( items : IFilterPart [ ] , item ?: any , index ?: number , column ?: IColumn ) : JSX . Element => {
0 commit comments