Skip to content

Commit 133a430

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Pass full range, since same field can have multiple roots.
1 parent 4fbc2dc commit 133a430

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,27 +131,30 @@ export class IgxGridUnmergeActivePipe implements PipeTransform {
131131
}
132132

133133
// collect full range of data to unmerge
134-
const dataToUnmerge = new Set();
135134
let startIndex;
135+
let endIndex;
136136
uniqueRoots.forEach(x => {
137137
const index = collection.indexOf(x);
138138
if (!startIndex) {
139139
startIndex = index;
140140
} else {
141141
startIndex = Math.min(startIndex, index);
142142
}
143-
dataToUnmerge.add(x.recordRef);
144143
const colKeys = [...x.cellMergeMeta.keys()];
145144
const cols = colsToMerge.filter(col => colKeys.indexOf(col.field) !== -1);
146145
for (const col of cols) {
147146
const childData = x.cellMergeMeta.get(col.field).childRecords;
148147
const childRecs = childData.map(rec => rec.recordRef);
149-
childRecs.forEach(child => dataToUnmerge.add(child));
148+
if (!endIndex) {
149+
endIndex = index + childRecs.length;
150+
} else {
151+
endIndex = Math.max(endIndex, index + childRecs.length + 1);
152+
}
150153
}
151154
});
152-
155+
const dataToUnmerge = collection.slice(startIndex, endIndex).map(x => x.recordRef);
153156
// unmerge data where active row index breaks merge groups
154-
const res = DataUtil.merge(Array.from(dataToUnmerge), colsToMerge, this.grid.mergeStrategy, activeRowIndexes.map(ri => ri - startIndex), this.grid);
157+
const res = DataUtil.merge(dataToUnmerge, colsToMerge, this.grid.mergeStrategy, activeRowIndexes.map(ri => ri - startIndex), this.grid);
155158
collection = collection.slice(0, startIndex).concat(res, collection.slice(startIndex + res.length));
156159
return collection;
157160
}

0 commit comments

Comments
 (0)