Skip to content

Commit 9b6689b

Browse files
Merge branch '17.2.x' into mkirkova/fix-14086-17.2.x
2 parents 74db265 + 6ba84e6 commit 9b6689b

19 files changed

+2138
-27
lines changed

projects/igniteui-angular/src/lib/combo/combo.common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
180180
if (selection) {
181181
this.selectionService.set(this._id, selection);
182182
}
183-
if (this.dropdown.open) {
183+
if (this.dropdown?.open) {
184184
this.dropdown.close();
185185
}
186186
if (this.inputGroup?.isFocused) {

projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,22 @@ describe('igxCombo', () => {
11531153
caseSensitiveIcon = fixture.debugElement.query(By.css('igx-icon[name=\'case-sensitive\']'));
11541154
expect(caseSensitiveIcon).toBeNull();
11551155
});
1156+
it('should render the combo component with the id set and not throw an error', () => {
1157+
fixture = TestBed.createComponent(ComboWithIdComponent);
1158+
fixture.detectChanges();
1159+
1160+
combo = fixture.componentInstance.combo;
1161+
fixture.detectChanges();
1162+
1163+
expect(combo).toBeTruthy();
1164+
expect(combo.id).toEqual("id1");
1165+
fixture.detectChanges();
1166+
1167+
const errorSpy = spyOn(console, 'error');
1168+
fixture.detectChanges();
1169+
1170+
expect(errorSpy).not.toHaveBeenCalled();
1171+
});
11561172
});
11571173
describe('Positioning tests: ', () => {
11581174
let containerElement: any;
@@ -3875,3 +3891,32 @@ export class ComboArrayTypeValueKeyComponent {
38753891
];
38763892
}
38773893
}
3894+
3895+
@Component({
3896+
template: `
3897+
<igx-combo id="id1" [data]="items" valueKey="value" displayKey="item"></igx-combo>`,
3898+
standalone: true,
3899+
imports: [IgxComboComponent]
3900+
})
3901+
export class ComboWithIdComponent {
3902+
@ViewChild(IgxComboComponent, { read: IgxComboComponent, static: true })
3903+
public combo: IgxComboComponent;
3904+
public items: any[] = [];
3905+
3906+
constructor() {
3907+
this.items = [
3908+
{
3909+
item: "Item1",
3910+
value: "Option1"
3911+
},
3912+
{
3913+
item: "Item2",
3914+
value: "Option2"
3915+
},
3916+
{
3917+
item: "Item3",
3918+
value: "Option3",
3919+
}
3920+
];
3921+
}
3922+
}

projects/igniteui-angular/src/lib/directives/drag-drop/drag-drop.directive.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,10 @@ export class IgxDragDirective implements AfterContentInit, OnDestroy {
14631463

14641464
/** Method setting transformation to the base draggable element. */
14651465
protected setTransformXY(x: number, y: number) {
1466+
if(x === 0 && y === 0) {
1467+
this.element.nativeElement.style.transform = '';
1468+
return;
1469+
}
14661470
this.element.nativeElement.style.transform = 'translate3d(' + x + 'px, ' + y + 'px, 0px)';
14671471
}
14681472

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,6 @@ export class IgxForOfDirective<T, U extends T[] = T[]> extends IgxForOfToken<T,U
798798
|| containerSize && endTopOffset - containerSize > 5;
799799
}
800800

801-
802801
/**
803802
* @hidden
804803
* Function that recalculates and updates cache sizes.
@@ -827,13 +826,13 @@ export class IgxForOfDirective<T, U extends T[] = T[]> extends IgxForOfToken<T,U
827826
const currDiff = newVal - oldVal;
828827
diffs.push(currDiff);
829828
totalDiff += currDiff;
830-
this.sizesCache[index + 1] += totalDiff;
829+
this.sizesCache[index + 1] = (this.sizesCache[index] || 0) + newVal;
831830
}
832831
}
833832
// update cache
834833
if (Math.abs(totalDiff) > 0) {
835834
for (let j = this.state.startIndex + this.state.chunkSize + 1; j < this.sizesCache.length; j++) {
836-
this.sizesCache[j] += totalDiff;
835+
this.sizesCache[j] = (this.sizesCache[j] || 0) + totalDiff;
837836
}
838837

839838
// update scrBar heights/widths

projects/igniteui-angular/src/lib/grids/grid/grid.component.spec.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { ISortingExpression, SortingDirection } from '../../data-operations/sort
2626
import { GRID_SCROLL_CLASS } from '../../test-utils/grid-functions.spec';
2727
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
2828
import { IgxPaginatorComponent, IgxPaginatorContentDirective } from '../../paginator/paginator.component';
29-
import { IGridRowEventArgs, IgxGridFooterComponent, IgxGridRow, IgxGroupByRow, IgxSummaryRow } from '../public_api';
29+
import { IGridRowEventArgs, IgxColumnGroupComponent, IgxGridFooterComponent, IgxGridRow, IgxGroupByRow, IgxSummaryRow } from '../public_api';
3030
import { getComponentSize } from '../../core/utils';
3131

3232

@@ -1896,6 +1896,20 @@ describe('IgxGrid Component Tests #grid', () => {
18961896

18971897
expect(calcWidth).not.toBe(80);
18981898
});
1899+
1900+
it('should correctly autosize column headers inside column groups.', async () => {
1901+
const fix = TestBed.createComponent(IgxGridColumnHeaderInGroupAutoSizeComponent);
1902+
const grid = fix.componentInstance.grid;
1903+
grid.data = [{field1: "Test"}];
1904+
1905+
//waiting for reqeustAnimationFrame to finish
1906+
fix.detectChanges();
1907+
await wait(17);
1908+
fix.detectChanges();
1909+
1910+
const calcWidth = parseInt(grid.getColumnByName("field1").calcWidth);
1911+
expect(calcWidth).toBe(126);
1912+
});
18991913
});
19001914

19011915
describe('IgxGrid - API methods', () => {
@@ -2962,6 +2976,36 @@ export class IgxGridColumnHeaderAutoSizeComponent {
29622976

29632977
}
29642978

2979+
@Component({
2980+
template: `
2981+
<igx-grid #grid>
2982+
<igx-column-group>
2983+
<igx-column
2984+
field="field1"
2985+
header="Field 1 Header"
2986+
width="auto"
2987+
></igx-column>
2988+
<igx-column
2989+
field="field2"
2990+
header="Field 2 Header"
2991+
width="auto"
2992+
></igx-column>
2993+
<igx-column
2994+
field="field3"
2995+
header="Field 3 Header"
2996+
width="auto"
2997+
></igx-column>
2998+
</igx-column-group>
2999+
</igx-grid>`,
3000+
standalone: true,
3001+
imports: [IgxGridComponent, IgxColumnComponent, IgxColumnGroupComponent]
3002+
3003+
})
3004+
export class IgxGridColumnHeaderInGroupAutoSizeComponent {
3005+
@ViewChild('grid', { read: IgxGridComponent, static: true })
3006+
public grid: IgxGridComponent;
3007+
}
3008+
29653009
@Component({
29663010
template: `<igx-grid #grid [data]="data" [width]="'500px'" (columnInit)="initColumns($event)">
29673011
<igx-column *ngFor="let col of columns" [field]="col.key" [header]="col.key" [dataType]="col.dataType">

projects/igniteui-angular/src/lib/grids/grid/grid.master-detail.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,13 +590,14 @@ describe('IgxGrid Master Detail #grid', () => {
590590
setupGridScrollDetection(fix, grid);
591591
const targetCellElement = grid.gridAPI.get_cell_by_index(0, 'ContactName');
592592
UIInteractions.simulateClickAndSelectEvent(targetCellElement);
593+
await wait(DEBOUNCETIME);
593594
fix.detectChanges();
594595

595596
UIInteractions.triggerEventHandlerKeyDown('End', gridContent, false, false, true);
596-
await wait(DEBOUNCETIME);
597597
fix.detectChanges();
598598
await wait(DEBOUNCETIME);
599599
fix.detectChanges();
600+
await wait(DEBOUNCETIME);
600601

601602
const lastRow = grid.gridAPI.get_row_by_index(52);
602603
expect(lastRow).not.toBeUndefined();

projects/igniteui-angular/src/lib/grids/grid/grid.multi-row-layout.integration.spec.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { By } from '@angular/platform-browser';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
55
import { IgxGridComponent } from './grid.component';
66
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
7-
import { ViewChild, Component } from '@angular/core';
7+
import { ViewChild, Component, DebugElement } from '@angular/core';
88
import { IgxColumnLayoutComponent } from '../columns/column-layout.component';
99
import { wait, UIInteractions } from '../../test-utils/ui-interactions.spec';
1010
import { DefaultSortingStrategy, SortingDirection } from '../../data-operations/sorting-strategy';
@@ -30,6 +30,7 @@ interface ColGroupsType {
3030
describe('IgxGrid - multi-row-layout Integration #grid - ', () => {
3131
let fixture: ComponentFixture<FixtureType>;
3232
let grid: IgxGridComponent;
33+
const COLUMN_HEADER_CLASS = '.igx-grid-th';
3334
configureTestSuite((() => {
3435
return TestBed.configureTestingModule({
3536
imports: [
@@ -896,6 +897,30 @@ describe('IgxGrid - multi-row-layout Integration #grid - ', () => {
896897
expect((grid.verticalScrollContainer.getScroll().children[0] as HTMLElement).offsetHeight -
897898
grid.verticalScrollContainer.getScroll().offsetHeight).toBeLessThanOrEqual(0);
898899
}));
900+
901+
it('should create only one ghost element when dragging a column', async () => {
902+
const headers: DebugElement[] = fixture.debugElement.queryAll(By.css(COLUMN_HEADER_CLASS));
903+
904+
const header = headers[1].nativeElement;
905+
UIInteractions.simulatePointerEvent('pointerdown', header, 50, 50);
906+
await wait();
907+
fixture.detectChanges();
908+
909+
UIInteractions.simulatePointerEvent('pointermove', header, 56, 56);
910+
await wait(50);
911+
fixture.detectChanges();
912+
913+
UIInteractions.simulatePointerEvent('pointermove', header, 230, 30);
914+
await wait();
915+
fixture.detectChanges();
916+
917+
const ghost = fixture.debugElement.queryAll(By.css('.igx-grid__drag-ghost-image'));
918+
expect(ghost.length).toEqual(1);
919+
920+
UIInteractions.simulatePointerEvent('pointerup', header, 230, 30);
921+
await wait();
922+
fixture.detectChanges();
923+
});
899924
});
900925

901926
describe('Resizing', () => {
@@ -1335,6 +1360,19 @@ export class ColumnLayoutGroupingTestComponent extends ColumnLayoutPinningTestCo
13351360
{ field: 'Country', rowStart: 2, colStart: 2, groupable: true },
13361361
{ field: 'Address', rowStart: 3, colStart: 1, colEnd: 3 }
13371362
];
1363+
1364+
public override colGroups: ColGroupsType[] = [
1365+
{
1366+
group: 'group1',
1367+
pinned: true,
1368+
columns: this.cols2
1369+
},
1370+
{
1371+
group: 'group2',
1372+
pinned: false,
1373+
columns: this.cols1
1374+
}
1375+
];
13381376
}
13391377
@Component({
13401378
template: `

projects/igniteui-angular/src/lib/grids/headers/grid-header-group.component.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
<igx-grid-header-group *ngIf="!child.hidden" class="igx-grid-thead__subgroup"
1212
[ngClass]="child.headerGroupClasses"
1313
[ngStyle]="child.headerGroupStyles | igxHeaderGroupStyle:child:grid.pipeTrigger"
14-
[column]="child"
15-
[igxColumnMovingDrag]="child"
16-
[ghostHost]="grid.outlet.nativeElement"
17-
[attr.droppable]="true"
18-
[igxColumnMovingDrop]="child">
14+
[column]="child">
1915
</igx-grid-header-group>
2016
</ng-container>
2117
</div>
@@ -70,8 +66,8 @@
7066
[ngClass]="child.headerGroupClasses"
7167
[ngStyle]="child.headerGroupStyles | igxHeaderGroupStyle:child:grid.pipeTrigger"
7268
[column]="child"
73-
[style.min-width]="child.calcWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts"
74-
[style.flex-basis]="child.calcWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts">
69+
[style.min-width]="child.resolvedWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts"
70+
[style.flex-basis]="child.resolvedWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts">
7571
</igx-grid-header-group>
7672
</ng-container>
7773
</div>

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.virtualization.spec.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { IgxStringFilteringOperand } from '../../data-operations/filtering-condi
1414
import { GridFunctions } from '../../test-utils/grid-functions.spec';
1515
import { HierarchicalGridFunctions } from '../../test-utils/hierarchical-grid-functions.spec';
1616
import { IgxHierarchicalRowComponent } from './hierarchical-row.component';
17+
import { IgxHierarchicalGridDefaultComponent } from '../../test-utils/hierarchical-grid-components.spec';
1718

1819
describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
1920
let fixture;
@@ -22,7 +23,8 @@ describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
2223
return TestBed.configureTestingModule({
2324
imports: [
2425
NoopAnimationsModule,
25-
IgxHierarchicalGridTestBaseComponent
26+
IgxHierarchicalGridTestBaseComponent,
27+
IgxHierarchicalGridDefaultComponent
2628
]
2729
});
2830
}));
@@ -393,6 +395,45 @@ describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
393395
expect(ri.gridScroll.emit).toHaveBeenCalled();
394396
expect(ri.dataPreLoad.emit).toHaveBeenCalled();
395397
});
398+
399+
it('should recalculate and update content correctly after filter is cleared, ensuring no empty areas post-filtering and scrolling', async () => {
400+
// eslint-disable-next-line @typescript-eslint/no-shadow
401+
const fixture = TestBed.createComponent(IgxHierarchicalGridDefaultComponent);
402+
fixture.detectChanges();
403+
// eslint-disable-next-line @typescript-eslint/no-shadow
404+
const hierarchicalGrid = fixture.componentInstance.hierarchicalGrid;
405+
fixture.detectChanges();
406+
await wait(50);
407+
408+
hierarchicalGrid.filter('Artist', 'd', IgxStringFilteringOperand.instance().condition('contains'));
409+
fixture.detectChanges();
410+
await wait(50);
411+
412+
hierarchicalGrid.expandRow(6);
413+
fixture.detectChanges();
414+
await wait(50);
415+
416+
hierarchicalGrid.verticalScrollContainer.getScroll().scrollTop = 2000;
417+
fixture.detectChanges();
418+
await wait(50);
419+
420+
hierarchicalGrid.clearFilter();
421+
fixture.detectChanges();
422+
await wait(50);
423+
424+
hierarchicalGrid.verticalScrollContainer.getScroll().scrollTop = 2000;
425+
fixture.detectChanges();
426+
await wait(50);
427+
fixture.detectChanges();
428+
await wait(50);
429+
430+
const hierarchicalGridRect = hierarchicalGrid.tbody.nativeElement.getBoundingClientRect();
431+
const lastRowRect = hierarchicalGrid.dataRowList.last.nativeElement.getBoundingClientRect();
432+
433+
const emptySpace = hierarchicalGridRect.bottom - lastRowRect.bottom;
434+
435+
expect(emptySpace).toBeLessThan(5);
436+
});
396437
});
397438

398439
describe('IgxHierarchicalGrid Virtualization Custom Scenarios #hGrid', () => {

projects/igniteui-angular/src/lib/grids/selection/selection.service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,10 @@ export class IgxGridSelectionService {
400400
return Array.from(this.rowSelection);
401401
}
402402
const selection = [];
403+
const gridDataMap = {};
404+
this.grid.gridAPI.get_all_data(true).forEach(row => gridDataMap[this.getRecordKey(row)] = row);
403405
this.rowSelection.forEach(rID => {
404-
const rData = this.grid.gridAPI.get_all_data(true).find(row => this.getRecordKey(row) === rID);
406+
const rData = gridDataMap[rID];
405407
const partialRowData = {};
406408
partialRowData[this.grid.primaryKey] = rID;
407409
selection.push(rData ? rData : partialRowData);
@@ -607,9 +609,9 @@ export class IgxGridSelectionService {
607609
if (this.allRowsSelected !== undefined && !newSelection) {
608610
return this.allRowsSelected;
609611
}
610-
const selectedData = newSelection ? newSelection : [...this.rowSelection]
612+
const selectedData = new Set(newSelection ? newSelection : [...this.rowSelection]);
611613
const allData = this.getRowIDs(this.allData);
612-
const unSelectedRows = allData.filter(row => !selectedData.includes(row));
614+
const unSelectedRows = allData.filter(row => !selectedData.has(row));
613615
return this.allRowsSelected = this.allData.length > 0 && unSelectedRows.length === 0;
614616
}
615617

0 commit comments

Comments
 (0)