Skip to content

Commit c3b3f24

Browse files
committed
fix(filter-ui): hide filtering row on column hide #6520
1 parent 26b0747 commit c3b3f24

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-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
@@ -253,6 +253,7 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy {
253253
this.grid.summaryService.resetSummaryHeight();
254254
this.grid.filteringService.refreshExpressions();
255255
this.grid.notifyChanges();
256+
this.grid.filteringService.hideColumnFilteringRowOnVisibilityChange(this);
256257
// this.grid.refreshSearch(true);
257258
}
258259
}

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+
* Internal method to create expressionsTree and filter grid used in both filter modes.
122+
*/
123+
public hideColumnFilteringRowOnVisibilityChange(col: IgxColumnComponent) {
124+
const filteringRow = col.grid.filteringRow;
121125

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

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

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3350,43 +3350,24 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
33503350
expect(grid.rowList.length).toBe(3);
33513351
});
33523352

3353-
it('Should close filter row when hide the current column', (async () => {
3354-
grid.height = '700px';
3355-
grid.showToolbar = true;
3356-
grid.columnHiding = true;
3357-
fix.detectChanges();
3358-
await wait(16);
3359-
3360-
const prodNameCol = grid.columns.find((col) => col.field === 'ProductName');
3361-
GridFunctions.verifyColumnIsHidden(prodNameCol, false, 6);
3362-
3353+
fit('Should close filter row when hide the current column', fakeAsync(() => {
33633354
GridFunctions.clickFilterCellChip(fix, 'ProductName');
3364-
fix.detectChanges();
33653355

33663356
// Check that the filterRow is opened
3367-
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3357+
let filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
33683358
expect(filterUIRow).not.toBeNull();
33693359

33703360
// Add first chip.
33713361
GridFunctions.typeValueInFilterRowInput('a', fix);
3372-
await wait(16);
3373-
3374-
const hideButton = GridFunctions.getColumnHidingButton(fix);
3375-
hideButton.focus();
3376-
fix.detectChanges();
3377-
await wait(16);
3378-
hideButton.click();
3379-
fix.detectChanges();
3380-
await wait(100);
3362+
tick(100);
33813363

3382-
const dropDown = fix.debugElement.query(By.css('igx-column-hiding'));
3383-
HelperUtils.getCheckboxInput('ProductName', dropDown, fix).click();
3364+
grid.getColumnByName('ProductName').hidden = true;
3365+
tick(100);
33843366
fix.detectChanges();
3385-
await wait(100);
33863367

33873368
// Check that the filterRow is closed
3388-
expect(fix.debugElement.query(By.css(FILTER_UI_ROW))).toBeNull();
3389-
GridFunctions.verifyColumnIsHidden(prodNameCol, true, 5);
3369+
filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3370+
expect(filterUIRow).toBeNull();
33903371
}));
33913372

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

0 commit comments

Comments
 (0)