diff --git a/CHANGELOG.md b/CHANGELOG.md index defdd756174..e2a57cf9ba5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ All notable changes for each version of this project will be documented in this - `IgxButtonDirective` - An `aria-label` set on the button, statically or through a binding, is no longer removed. The button changes `aria-label` only through `igxLabel`, and clearing `igxLabel` removes only the value it set (#18009). - Buttons that use `igxLabel` no longer receive the label styles of `IgxLabelDirective`, such as its text color (#18009). +- `IgxPivotGridComponent` + - In the horizontal row layout, a key press that scrolls to another row dimension header, such as `Home` or `End`, now highlights that header. Previously the header that was active before the key press stayed highlighted (#17932). ## 22.3.1 diff --git a/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid-navigation.service.ts b/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid-navigation.service.ts index 4d2d586815d..976b30f0e69 100644 --- a/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid-navigation.service.ts +++ b/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid-navigation.service.ts @@ -114,7 +114,9 @@ export class IgxPivotGridNavigationService extends IgxGridNavigationService { } this.setActiveNode(newActiveNode); - if (!this.grid.hasHorizontalLayout && verticalContainer.isIndexOutsideView(newActiveNode.row)) { + if (this.grid.hasHorizontalLayout) { + this.grid.notifyChanges(); + } else if (verticalContainer.isIndexOutsideView(newActiveNode.row)) { verticalContainer.scrollTo(newActiveNode.row); } } else { @@ -385,13 +387,11 @@ export class IgxPivotGridNavigationService extends IgxGridNavigationService { if (verticalContainer.isIndexOutsideView(nextDataViewIndex)) { verticalContainer.scrollTo(nextDataViewIndex); await new Promise((resolve) => { - this.grid.gridScroll.pipe(take(1), timeout({ first: 10000 })).subscribe({ + verticalContainer.chunkLoad.pipe(take(1), timeout({ first: 10000 })).subscribe({ next: (value) => resolve(value), error: (err) => resolve(err) }); }); - // Large scroll jumps only reassign the row contexts, so update the row dimension rows before looking them up. - this.grid.cdr.detectChanges(); } } diff --git a/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts b/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts index 1b1495e3262..bdf19767cd3 100644 --- a/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts +++ b/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts @@ -1,7 +1,8 @@ -import { SimpleChange } from '@angular/core'; +import { provideZonelessChangeDetection, SimpleChange } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { firstValueFrom } from 'rxjs'; import { ColumnPinningPosition, FilteringExpressionsTree, @@ -4583,6 +4584,7 @@ describe('IgxPivotGrid #pivotGrid', () => { }); it("should scroll to the row dimension cells outside of the view.", async () => { + fixture.autoDetectChanges(); pivotGrid.data = Array.from({ length: 30 }, (_, i) => ({ ProductCategory: 'Clothing', UnitPrice: 10, SellerName: `Seller ${i}`, Country: 'Bulgaria', City: `City ${i}`, Date: '01/01/2012', UnitsSold: i @@ -4621,6 +4623,7 @@ describe('IgxPivotGrid #pivotGrid', () => { }); it("should jump to the first and last row dimension cells outside of the view.", async () => { + fixture.autoDetectChanges(); pivotGrid.data = Array.from({ length: 30 }, (_, i) => ({ ProductCategory: 'Clothing', UnitPrice: 10, SellerName: `Seller ${i}`, Country: 'Bulgaria', City: `City ${i}`, Date: '01/01/2012', UnitsSold: i @@ -4664,6 +4667,50 @@ describe('IgxPivotGrid #pivotGrid', () => { }); }); + describe('IgxPivotGrid Horizontal Layout zoneless #pivotGrid', () => { + beforeEach(() => { + TestBed.configureTestingModule({ providers: [provideZonelessChangeDetection()] }); + }); + + it('should highlight the row dimension header that End and Home scroll to.', async () => { + const fixture = TestBed.createComponent(IgxPivotGridTestComplexHierarchyComponent); + fixture.detectChanges(); + const pivotGrid = fixture.componentInstance.pivotGrid; + pivotGrid.pivotUI = { showRowHeaders: true, rowLayout: PivotRowLayoutType.Horizontal }; + pivotGrid.data = Array.from({ length: 40 }, (_, i) => ({ + ProductCategory: i % 2 ? 'Bikes' : 'Clothing', City: `City ${i}`, Country: 'Bulgaria', Date: '01/01/2012', UnitsSold: i + })); + pivotGrid.pivotConfiguration.rows = [{ + memberName: 'AllProducts', memberFunction: () => 'All Products', enabled: true, horizontalSummary: true, + childLevel: { memberName: 'ProductCategory', enabled: true, horizontalSummary: true, childLevel: { memberName: 'City', enabled: true } } + }]; + pivotGrid.pipeTrigger++; + fixture.detectChanges(); + await fixture.whenStable(); + + const headers = () => fixture.debugElement.queryAll(By.directive(IgxPivotRowDimensionHeaderComponent)); + const activeHeaders = () => headers() + .filter(x => x.parent.nativeElement.classList.contains('igx-grid-th--active')) + .map(x => x.componentInstance.column.header); + const container = fixture.debugElement.query(By.css('.igx-grid__tbody-pivot-mrl-dimension')).nativeElement; + const pressKey = async (key: string) => { + const activeNodeChanged = firstValueFrom(pivotGrid.activeNodeChange); + UIInteractions.triggerKeyDownEvtUponElem(key, container); + await activeNodeChanged; + await fixture.whenStable(); + }; + + UIInteractions.simulateClickAndSelectEvent(headers().find(x => x.componentInstance.column.header === 'All Products')); + await fixture.whenStable(); + + await pressKey('End'); + expect(activeHeaders()).toEqual(['All Products Total']); + + await pressKey('Home'); + expect(activeHeaders()).toEqual(['All Products']); + }); + }); + describe('Template directives #pivotGrid', () => { let fixture: ComponentFixture;