@@ -88,10 +88,6 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
88
88
89
89
// Loop over all the groups
90
90
for ( const groupItems in groupedItems ) {
91
- // Add the items to the updated items order array
92
- groupedItems [ groupItems ] . forEach ( ( item ) => {
93
- updatedItemsOrder . push ( item ) ;
94
- } ) ;
95
91
// Retrieve the total number of items per group
96
92
const totalItems = groupedItems [ groupItems ] . length ;
97
93
// Create the new group
@@ -104,7 +100,16 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
104
100
// Check if child grouping available
105
101
if ( groupByFields [ level + 1 ] ) {
106
102
// Get the child groups
107
- group . children = this . _getGroups ( groupedItems [ groupItems ] , groupByFields , ( level + 1 ) , startIndex ) . groups ;
103
+ const subGroup = this . _getGroups ( groupedItems [ groupItems ] , groupByFields , ( level + 1 ) , startIndex ) ;
104
+ subGroup . items . forEach ( ( item ) => {
105
+ updatedItemsOrder . push ( item ) ;
106
+ } ) ;
107
+ group . children = subGroup . groups ;
108
+ } else {
109
+ // Add the items to the updated items order array
110
+ groupedItems [ groupItems ] . forEach ( ( item ) => {
111
+ updatedItemsOrder . push ( item ) ;
112
+ } ) ;
108
113
}
109
114
// Increase the start index for the next group
110
115
startIndex = startIndex + totalItems ;
0 commit comments