Skip to content

Commit 0136080

Browse files
authored
fix(merging): add additional handling for grid size change with merge on (#16199)
1 parent 0755126 commit 0136080

File tree

4 files changed

+106
-58
lines changed

4 files changed

+106
-58
lines changed

projects/igniteui-angular/src/lib/core/styles/components/grid/_grid-theme.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,18 @@
902902
map.get($grid-cell-padding-inline, 'cosy'),
903903
map.get($grid-cell-padding-inline, 'comfortable')
904904
);
905+
min-height: sizable(
906+
rem(32px),
907+
rem(40px),
908+
rem(50px)
909+
);
905910
} @else {
906911
padding-inline: pad-inline(rem(8px), rem(12px), rem(16px));
912+
min-height: sizable(
913+
rem(32px),
914+
rem(40px),
915+
rem(48px)
916+
);
907917

908918
igx-icon {
909919
opacity: if($theme-variant == 'light', .75, .85);
@@ -2736,6 +2746,19 @@
27362746
%igx-grid__tr-action {
27372747
&:last-of-type {
27382748
border-inline-end: var-get($theme, 'header-border-width') var-get($theme, 'header-border-style') var-get($theme, 'header-border-color');
2749+
@if $variant != 'indigo' {
2750+
min-height: sizable(
2751+
rem(32px),
2752+
rem(40px),
2753+
rem(50px)
2754+
);
2755+
} @else {
2756+
min-height: sizable(
2757+
rem(32px),
2758+
rem(40px),
2759+
rem(48px)
2760+
);
2761+
}
27392762
}
27402763
}
27412764

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,7 +2517,7 @@ export abstract class IgxGridBaseDirective implements GridType,
25172517
public get mergeStrategy() {
25182518
return this._mergeStrategy;
25192519
}
2520-
public set mergeStrategy(value) {
2520+
public set mergeStrategy(value) {
25212521
this._mergeStrategy = value;
25222522
}
25232523

@@ -3119,7 +3119,7 @@ export abstract class IgxGridBaseDirective implements GridType,
31193119
/**
31203120
* @hidden @internal
31213121
*/
3122-
public hoverIndex: number;
3122+
public hoverIndex: number;
31233123

31243124
/**
31253125
* @hidden @internal
@@ -4001,22 +4001,22 @@ export abstract class IgxGridBaseDirective implements GridType,
40014001
* @hidden
40024002
* @internal
40034003
*/
4004-
public get columnsToMerge() : ColumnType[] {
4004+
public get columnsToMerge(): ColumnType[] {
40054005
if (this._columnsToMerge.length) {
40064006
return this._columnsToMerge;
40074007
}
40084008
const cols = this.visibleColumns.filter(
4009-
x => x.merge && (this.cellMergeMode ==='always' ||
4010-
(this.cellMergeMode === 'onSort' && !!this.sortingExpressions.find( y => y.fieldName === x.field)))
4009+
x => x.merge && (this.cellMergeMode === 'always' ||
4010+
(this.cellMergeMode === 'onSort' && !!this.sortingExpressions.find(y => y.fieldName === x.field)))
40114011
);
40124012
this._columnsToMerge = cols;
40134013
return this._columnsToMerge;
40144014
}
40154015

40164016
protected allowResetOfColumnsToMerge() {
40174017
const cols = this.visibleColumns.filter(
4018-
x => x.merge && (this.cellMergeMode ==='always' ||
4019-
(this.cellMergeMode === 'onSort' && !!this.sortingExpressions.find( y => y.fieldName === x.field)))
4018+
x => x.merge && (this.cellMergeMode === 'always' ||
4019+
(this.cellMergeMode === 'onSort' && !!this.sortingExpressions.find(y => y.fieldName === x.field)))
40204020
);
40214021
if (areEqualArrays(cols, this._columnsToMerge)) {
40224022
return false;
@@ -5650,6 +5650,9 @@ export abstract class IgxGridBaseDirective implements GridType,
56505650
* The rowHeight input is bound to min-height css prop of rows that adds a 1px border in all cases
56515651
*/
56525652
public get renderedRowHeight(): number {
5653+
if (this.hasCellsToMerge) {
5654+
return this.rowHeight;
5655+
}
56535656
return this.rowHeight + 1;
56545657
}
56555658

@@ -7740,9 +7743,9 @@ export abstract class IgxGridBaseDirective implements GridType,
77407743
const virtRec = this.verticalScrollContainer.igxForOf[targetRowIndex];
77417744
const col = typeof (column) === 'number' ? this.visibleColumns[column] : column;
77427745
const rowSpan = this.isRecordMerged(virtRec) ? virtRec?.cellMergeMeta.get(col)?.rowSpan : 1;
7743-
if (rowSpan > 1) {
7744-
targetRowIndex += Math.floor(rowSpan/2);
7745-
}
7746+
if (rowSpan > 1) {
7747+
targetRowIndex += Math.floor(rowSpan / 2);
7748+
}
77467749
if (delayScrolling) {
77477750
this.verticalScrollContainer.dataChanged.pipe(first(), takeUntil(this.destroy$)).subscribe(() => {
77487751
this.scrollDirective(this.verticalScrollContainer,
@@ -8096,10 +8099,10 @@ export abstract class IgxGridBaseDirective implements GridType,
80968099
if (this.hasCellsToMerge) {
80978100
let indexes = this.activeRowIndexes;
80988101
if (this.page > 0) {
8099-
indexes = indexes.map(x => this.perPage * this.page + x );
8102+
indexes = indexes.map(x => this.perPage * this.page + x);
81008103
}
81018104

8102-
data = DataUtil.merge(cloneArray(this.filteredSortedData), this.columnsToMerge, this.mergeStrategy, indexes, this);
8105+
data = DataUtil.merge(cloneArray(this.filteredSortedData), this.columnsToMerge, this.mergeStrategy, indexes, this);
81038106
}
81048107
const columnItems = this.visibleColumns.filter((c) => !c.columnGroup).sort((c1, c2) => c1.visibleIndex - c2.visibleIndex);
81058108
const columnsPathParts = columnItems.map(col => columnFieldPath(col.field));
@@ -8115,7 +8118,7 @@ export abstract class IgxGridBaseDirective implements GridType,
81158118
: resolveNestedPath(currentRowData, columnsPathParts[cid]);
81168119
if (value !== undefined && value !== null && c.searchable) {
81178120
let searchValue = caseSensitive ? String(value) : String(value).toLowerCase();
8118-
const isMergePlaceHolder = this.isRecordMerged(dataRow) ? !!dataRow?.cellMergeMeta.get(c.field)?.root : false;
8121+
const isMergePlaceHolder = this.isRecordMerged(dataRow) ? !!dataRow?.cellMergeMeta.get(c.field)?.root : false;
81198122
if (exactMatch) {
81208123
if (searchValue === searchText && !isMergePlaceHolder) {
81218124
const mic: IMatchInfoCache = {
@@ -8256,7 +8259,7 @@ export abstract class IgxGridBaseDirective implements GridType,
82568259
this._rowCount += 1; // include header row
82578260
}
82588261

8259-
private updateMergedData(){
8262+
private updateMergedData() {
82608263
// recalc merged data
82618264
if (this.columnsToMerge.length > 0) {
82628265
const startIndex = this.verticalScrollContainer.state.startIndex;
@@ -8267,9 +8270,9 @@ export abstract class IgxGridBaseDirective implements GridType,
82678270
if (rec.cellMergeMeta &&
82688271
// index + maxRowSpan is within view
82698272
startIndex < (index + Math.max(...rec.cellMergeMeta.values().toArray().map(x => x.rowSpan)))) {
8270-
const visibleIndex = this.isRowPinningToTop ? index + this.pinnedRecordsCount : index;
8271-
data.push({record: rec, index: visibleIndex, dataIndex: index });
8272-
}
8273+
const visibleIndex = this.isRowPinningToTop ? index + this.pinnedRecordsCount : index;
8274+
data.push({ record: rec, index: visibleIndex, dataIndex: index });
8275+
}
82738276
}
82748277
this._mergedDataInView = data;
82758278
this.notifyChanges();

0 commit comments

Comments
 (0)