Skip to content

Commit 8623eb1

Browse files
authored
Merge pull request #7151 from IgniteUI/ibarakov/fix-6520-8.2.x
fix(filter-ui): hide filtering row on column hide #6520
2 parents d1ee10c + 272e384 commit 8623eb1

File tree

3 files changed

+18
-31
lines changed

3 files changed

+18
-31
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy {
252252
this.grid.endEdit(false);
253253
this.grid.summaryService.resetSummaryHeight();
254254
this.grid.filteringService.refreshExpressions();
255+
this.grid.filteringService.hideFilteringRowOnColumnVisibilityChange(this);
255256
this.grid.notifyChanges();
256257
// this.grid.refreshSearch(true);
257258
}

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
@@ -114,13 +114,17 @@ export class IgxFilteringService implements OnDestroy {
114114
filterCell.updateFilterCellArea();
115115
});
116116
});
117+
}
118+
}
117119

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

122-
}
123-
});
126+
if (filteringRow && filteringRow.column && filteringRow.column === col) {
127+
filteringRow.close();
124128
}
125129
}
126130

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

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3330,43 +3330,25 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
33303330
expect(grid.rowList.length).toBe(3);
33313331
});
33323332

3333-
it('Should close filter row when hide the current column', (async () => {
3334-
grid.height = '700px';
3335-
grid.showToolbar = true;
3336-
grid.columnHiding = true;
3337-
fix.detectChanges();
3338-
await wait(16);
3339-
3340-
const prodNameCol = grid.columns.find((col) => col.field === 'ProductName');
3341-
GridFunctions.verifyColumnIsHidden(prodNameCol, false, 6);
3342-
3333+
it('Should close filter row when hide the current column', fakeAsync(() => {
33433334
GridFunctions.clickFilterCellChip(fix, 'ProductName');
3344-
fix.detectChanges();
33453335

33463336
// Check that the filterRow is opened
3347-
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3337+
let filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
33483338
expect(filterUIRow).not.toBeNull();
33493339

33503340
// Add first chip.
33513341
GridFunctions.typeValueInFilterRowInput('a', fix);
3352-
await wait(16);
3353-
3354-
const hideButton = GridFunctions.getColumnHidingButton(fix);
3355-
hideButton.focus();
3356-
fix.detectChanges();
3357-
await wait(16);
3358-
hideButton.click();
3359-
fix.detectChanges();
3360-
await wait(100);
3342+
tick(100);
33613343

3362-
const dropDown = fix.debugElement.query(By.css('igx-column-hiding'));
3363-
HelperUtils.getCheckboxInput('ProductName', dropDown, fix).click();
3344+
grid.getColumnByName('ProductName').hidden = true;
3345+
tick(100);
33643346
fix.detectChanges();
3365-
await wait(100);
33663347

33673348
// Check that the filterRow is closed
3368-
expect(fix.debugElement.query(By.css(FILTER_UI_ROW))).toBeNull();
3369-
GridFunctions.verifyColumnIsHidden(prodNameCol, true, 5);
3349+
filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3350+
expect(filterUIRow).toBeNull();
3351+
expect(grid.rowList.length).toBe(3, 'filter is not applied');
33703352
}));
33713353

33723354
it('Unary conditions should be committable', fakeAsync(() => {

0 commit comments

Comments
 (0)