From ee9d293cb5b7e0c54425e6baf96b0d3a4f16cea3 Mon Sep 17 00:00:00 2001 From: Stefan Stoyanov Date: Mon, 3 Dec 2018 15:55:22 +0200 Subject: [PATCH] fix(igx-grid): Reset isFilterRowVisible, when changing allowFiltering, #3255 --- .../src/lib/grids/grid-base.component.ts | 2 ++ .../lib/grids/grid/grid-filtering-ui.spec.ts | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/projects/igniteui-angular/src/lib/grids/grid-base.component.ts b/projects/igniteui-angular/src/lib/grids/grid-base.component.ts index f653723438a..a37eb5ede07 100644 --- a/projects/igniteui-angular/src/lib/grids/grid-base.component.ts +++ b/projects/igniteui-angular/src/lib/grids/grid-base.component.ts @@ -745,6 +745,8 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements set allowFiltering(value) { if (this._allowFiltering !== value) { this._allowFiltering = value; + this.filteringService.isFilterRowVisible = false; + this.filteringService.filteredColumn = null; this.filteringService.registerSVGIcons(); if (this.gridAPI.get(this.id)) { this.markForCheck(); diff --git a/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts b/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts index 74e2e9f865b..0d7c4cc932b 100644 --- a/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts @@ -2689,6 +2689,27 @@ describe('IgxGrid - Filtering Row UI actions', () => { igx_grid_filter_row_close: 'Close' }); })); + + it('Should remove FilterRow, when allowFiltering is set to false.', fakeAsync(() => { + const fix = TestBed.createComponent(IgxGridFilteringComponent); + const grid = fix.componentInstance.grid; + fix.detectChanges(); + + const initialChips = fix.debugElement.queryAll(By.directive(IgxChipComponent)); + const stringCellChip = initialChips[0].nativeElement; + + stringCellChip.click(); + fix.detectChanges(); + + let filteringRow = fix.debugElement.query(By.directive(IgxGridFilteringRowComponent)); + expect(filteringRow).toBeDefined(); + + grid.allowFiltering = false; + fix.detectChanges(); + + filteringRow = fix.debugElement.query(By.directive(IgxGridFilteringRowComponent)); + expect(filteringRow).toBeNull(); + })); }); export class CustomFilter extends IgxFilteringOperand {