Skip to content

Commit 96e0b25

Browse files
authored
Merge pull request #7152 from IgniteUI/ibarakov/fix-6520-9.0.x
fix(filter-ui): hide filtering row on column hide #6520
2 parents 55c61df + 7e15a19 commit 96e0b25

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

projects/igniteui-angular/src/lib/grids/columns/column.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ export class IgxColumnComponent implements AfterContentInit {
251251
this.grid.endEdit(false);
252252
this.grid.summaryService.resetSummaryHeight();
253253
this.grid.filteringService.refreshExpressions();
254+
this.grid.filteringService.hideFilteringRowOnColumnVisibilityChange(this);
254255
this.grid.notifyChanges();
255256
}
256257
}

projects/igniteui-angular/src/lib/grids/filtering/grid-filtering.service.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,17 @@ export class IgxFilteringService implements OnDestroy {
116116
filterCell.updateFilterCellArea();
117117
});
118118
});
119+
}
120+
}
119121

120-
this.grid.onColumnVisibilityChanged.pipe(takeUntil(this.destroy$)).subscribe((eventArgs: IColumnVisibilityChangedEventArgs) => {
121-
if (this.grid.filteringRow && this.grid.filteringRow.column === eventArgs.column ) {
122-
this.grid.filteringRow.close();
122+
/**
123+
* Close filtering row if a column is hidden.
124+
*/
125+
public hideFilteringRowOnColumnVisibilityChange(col: IgxColumnComponent) {
126+
const filteringRow = this.grid.filteringRow;
123127

124-
}
125-
});
128+
if (filteringRow && filteringRow.column && filteringRow.column === col) {
129+
filteringRow.close();
126130
}
127131
}
128132

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,24 +2123,24 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
21232123
}));
21242124

21252125
it('Should close filter row when hide the current column', fakeAsync(() => {
2126-
pending('This issue is failing because of bug #');
21272126
GridFunctions.clickFilterCellChip(fix, 'ProductName');
21282127

21292128
// Check that the filterRow is opened
2130-
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
2129+
let filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
21312130
expect(filterUIRow).not.toBeNull();
21322131

21332132
// Add first chip.
21342133
GridFunctions.typeValueInFilterRowInput('a', fix);
21352134
tick(100);
21362135

21372136
grid.getColumnByName('ProductName').hidden = true;
2138-
fix.detectChanges();
21392137
tick(100);
2138+
fix.detectChanges();
21402139

21412140
// Check that the filterRow is closed
2142-
expect(fix.debugElement.query(By.css(FILTER_UI_ROW))).toBeNull();
2143-
expect(grid.rowList.length).toBe(8);
2141+
filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
2142+
expect(filterUIRow).toBeNull();
2143+
expect(grid.rowList.length).toBe(3, 'filter is not applied');
21442144
}));
21452145

21462146
it('Should keep existing column filter after hiding another column.', fakeAsync(() => {

0 commit comments

Comments
 (0)