Skip to content

Commit a06c76f

Browse files
Merge branch 'master' into ganastasov/fix-17275-master
2 parents 1ec9838 + 2a8f288 commit a06c76f

6 files changed

Lines changed: 540 additions & 6 deletions

File tree

projects/igniteui-angular/date-picker/src/date-picker/date-picker.component.spec.ts

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
OverlayCancelableEventArgs, OverlayClosingEventArgs, OverlayEventArgs, OverlaySettings,
1414
WEEKDAYS
1515
} from 'igniteui-angular/core';
16-
import { ChangeDetectorRef, Component, DebugElement, ElementRef, EventEmitter, Injector, QueryList, Renderer2, ViewChild } from '@angular/core';
16+
import { ChangeDetectorRef, Component, DebugElement, ElementRef, EventEmitter, Injector, provideZonelessChangeDetection, QueryList, Renderer2, ViewChild } from '@angular/core';
1717
import { By } from '@angular/platform-browser';
1818
import { PickerCalendarOrientation, PickerHeaderOrientation, PickerInteractionMode } from '../../../core/src/date-common/types';
1919
import { DatePart } from '../../../core/src/date-common/public_api';
@@ -903,8 +903,8 @@ describe('IgxDatePicker', () => {
903903
get: mockNgControl
904904
});
905905

906-
mockCdr = jasmine.createSpyObj('ChangeDetectorRef', ['detectChanges']);
907-
mockCalendar = { selected: new EventEmitter<any>(), selectDate: () => {} };
906+
mockCdr = jasmine.createSpyObj('ChangeDetectorRef', ['detectChanges', 'markForCheck']);
907+
mockCalendar = { selected: new EventEmitter<any>(), selectDate: () => { } };
908908
const mockComponentInstance = {
909909
calendar: mockCalendar,
910910
todaySelection: new EventEmitter<any>(),
@@ -1665,6 +1665,44 @@ describe('IgxDatePicker', () => {
16651665
});
16661666
});
16671667
});
1668+
1669+
describe('Zoneless', () => {
1670+
let fixture: ComponentFixture<IgxDatePickerNgModelComponent>;
1671+
let datePicker: IgxDatePickerComponent;
1672+
1673+
beforeEach(async () => {
1674+
await TestBed.configureTestingModule({
1675+
imports: [
1676+
NoopAnimationsModule,
1677+
IgxDatePickerNgModelComponent,
1678+
],
1679+
providers: [
1680+
provideZonelessChangeDetection()
1681+
]
1682+
}).compileComponents();
1683+
1684+
fixture = TestBed.createComponent(IgxDatePickerNgModelComponent);
1685+
fixture.detectChanges();
1686+
});
1687+
1688+
it('should not throw ExpressionChangedAfterItHasBeenCheckedError when closing - issue #17305', fakeAsync(() => {
1689+
datePicker = fixture.componentInstance.datePicker;
1690+
1691+
datePicker.open();
1692+
fixture.detectChanges();
1693+
tick();
1694+
1695+
expect(() => {
1696+
datePicker.close();
1697+
fixture.detectChanges();
1698+
}).not.toThrow();
1699+
1700+
fixture.detectChanges();
1701+
tick(100);
1702+
const input = fixture.debugElement.query(By.css('input'));
1703+
expect(input.nativeElement.getAttribute('aria-expanded')).toBe('false');
1704+
}));
1705+
});
16681706
});
16691707
@Component({
16701708
template: `

projects/igniteui-angular/date-picker/src/date-picker/date-picker.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ export class IgxDatePickerComponent extends PickerBaseDirective implements Contr
904904
this._initializeCalendarContainer(e.componentRef.instance);
905905
this._calendarContainer = e.componentRef.location.nativeElement;
906906
this._collapsed = false;
907+
this.cdr.markForCheck();
907908
});
908909

909910
this._overlayService.opened.pipe(...this._overlaySubFilter).subscribe(() => {
@@ -936,6 +937,7 @@ export class IgxDatePickerComponent extends PickerBaseDirective implements Contr
936937
this._overlayId = null;
937938
this._calendar = null;
938939
this._calendarContainer = undefined;
940+
this.cdr.markForCheck();
939941
});
940942
}
941943

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7767,12 +7767,18 @@ export abstract class IgxGridBaseDirective implements GridType,
77677767
this.verticalScrollContainer.onScroll(event);
77687768
this.disableTransitions = true;
77697769

7770-
this.zone.onStable.pipe(first()).subscribe(() => {
7770+
const callback = () => {
77717771
this.verticalScrollContainer.chunkLoad.emit(this.verticalScrollContainer.state);
77727772
if (this.rowEditable) {
77737773
this.changeRowEditingOverlayStateOnScroll(this.crudService.rowInEditMode);
77747774
}
7775-
});
7775+
};
7776+
if (this.isZonelessChangeDetection()) {
7777+
this.cdr.detectChanges();
7778+
callback();
7779+
} else {
7780+
this.zone.onStable.pipe(first()).subscribe(callback);
7781+
}
77767782
this.disableTransitions = false;
77777783

77787784
this.hideOverlays();
@@ -7797,6 +7803,10 @@ export abstract class IgxGridBaseDirective implements GridType,
77977803
this.gridScroll.emit(args);
77987804
}
77997805

7806+
protected isZonelessChangeDetection(): boolean {
7807+
return this.zone.constructor.name === 'NoopNgZone';
7808+
}
7809+
78007810
protected hasMenuPinningActions(): boolean {
78017811
const strip = this.actionStrip;
78027812
const actionButtons = strip?.actionButtons;

projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
[igxForContainerSize]="calcHeight"
176176
[igxForItemSize]="renderedRowHeight"
177177
[igxForSizePropName]="'height'"
178+
[igxForTrackBy]="trackHorizontalRowGroup"
178179
>
179180
<div [attr.data-index]="rowIndex">
180181
<igx-pivot-row-dimension-mrl-row [rowIndex]="rowIndex" [rowGroup]="rowGroup" [groupedData]="groupedData" [style.height.px]="renderedRowHeight * rowGroup.length"></igx-pivot-row-dimension-mrl-row>

projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AfterContentInit, AfterViewInit, ChangeDetectionStrategy, Component, Ev
22
import { NgTemplateOutlet, NgClass, NgStyle } from '@angular/common';
33

44
import { first, take, takeUntil } from 'rxjs/operators';
5-
import { DEFAULT_PIVOT_KEYS, IDimensionsChange, IgxFilteringService, IgxGridNavigationService, IgxGridValidationService, IgxPivotDateDimension, IgxPivotGridValueTemplateContext, IPivotConfiguration, IPivotConfigurationChangedEventArgs, IPivotDimension, IPivotUISettings, IPivotValue, IValuesChange, PivotDimensionType, PivotRowLayoutType, PivotSummaryPosition, PivotUtil } from 'igniteui-angular/grids/core';
5+
import { DEFAULT_PIVOT_KEYS, IDimensionsChange, IgxFilteringService, IgxGridNavigationService, IgxGridValidationService, IgxPivotDateDimension, IgxPivotGridValueTemplateContext, IPivotConfiguration, IPivotConfigurationChangedEventArgs, IPivotDimension, IPivotGridRecord, IPivotUISettings, IPivotValue, IValuesChange, PivotDimensionType, PivotRowLayoutType, PivotSummaryPosition, PivotUtil } from 'igniteui-angular/grids/core';
66
import { IgxGridSelectionService } from 'igniteui-angular/grids/core';
77
import { GridType, IGX_GRID_BASE, IGX_GRID_SERVICE_BASE, IgxColumnTemplateContext, PivotGridType, RowType } from 'igniteui-angular/grids/core';
88
import { IgxGridCRUDService } from 'igniteui-angular/grids/core';
@@ -2485,6 +2485,8 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
24852485
}
24862486
}
24872487

2488+
protected trackHorizontalRowGroup = (_index: number, rowGroup: IPivotGridRecord[]) => rowGroup[0]?.dataIndex;
2489+
24882490
/**
24892491
* @hidden @internal
24902492
*/

0 commit comments

Comments
 (0)