Skip to content

Commit e0e6542

Browse files
authored
Merge pull request #5524 from IgniteUI/astaev/issue5304-7.3.x
fix(filtering): Scroll chips before remove #5304
2 parents 23dc339 + 59475b3 commit e0e6542

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
758758
const containerRect = this.container.nativeElement.getBoundingClientRect();
759759

760760
for (let index = 0; index < chipAraeChildren.length; index++) {
761-
if (Math.ceil(chipAraeChildren[index].getBoundingClientRect().left) < Math.ceil(containerRect.left)) {
761+
if (Math.ceil(chipAraeChildren[index].getBoundingClientRect().right) < Math.ceil(containerRect.left)) {
762762
count++;
763763
}
764764
}

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3246,6 +3246,69 @@ describe('IgxGrid - Filtering Row UI actions', () => {
32463246
const chipDiv = GridFunctions.getFilterConditionChip(fix, 0).querySelector('.igx-chip__item');
32473247
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBe(true, 'chip is not selected');
32483248
}));
3249+
3250+
it('Should not throw error when deleting the last chip', (async () => {
3251+
grid.width = '700px';
3252+
fix.detectChanges();
3253+
await wait(100);
3254+
3255+
GridFunctions.clickFilterCellChip(fix, 'ProductName');
3256+
fix.detectChanges();
3257+
3258+
// Add first chip.
3259+
GridFunctions.typeValueInFilterRowInput('a', fix);
3260+
await wait(16);
3261+
GridFunctions.submitFilterRowInput(fix);
3262+
await wait(100);
3263+
// Add second chip.
3264+
GridFunctions.typeValueInFilterRowInput('e', fix);
3265+
await wait(16);
3266+
GridFunctions.submitFilterRowInput(fix);
3267+
await wait(100);
3268+
// Add third chip.
3269+
GridFunctions.typeValueInFilterRowInput('i', fix);
3270+
await wait(16);
3271+
GridFunctions.submitFilterRowInput(fix);
3272+
await wait(100);
3273+
// Add fourth chip.
3274+
GridFunctions.typeValueInFilterRowInput('o', fix);
3275+
await wait(16);
3276+
GridFunctions.submitFilterRowInput(fix);
3277+
await wait(200);
3278+
3279+
verifyMultipleChipsVisibility(fix, [false, false, false, true]);
3280+
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3281+
let chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
3282+
expect(chips.length).toBe(4);
3283+
3284+
const leftArrowButton = GridFunctions.getFilterRowLeftArrowButton(fix).nativeElement;
3285+
expect(leftArrowButton).toBeTruthy('Left scroll arrow should be visible');
3286+
3287+
const rightArrowButton = GridFunctions.getFilterRowRightArrowButton(fix).nativeElement;
3288+
expect(rightArrowButton).toBeTruthy('Right scroll arrow should be visible');
3289+
expect(grid.rowList.length).toBe(2);
3290+
3291+
let chipToRemove = filterUIRow.componentInstance.expressionsList[3];
3292+
expect(() => { filterUIRow.componentInstance.onChipRemoved(null, chipToRemove); })
3293+
.not.toThrowError(/\'id\' of undefined/);
3294+
await wait(200);
3295+
fix.detectChanges();
3296+
3297+
verifyMultipleChipsVisibility(fix, [false, true, false]);
3298+
chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
3299+
expect(chips.length).toBe(3);
3300+
3301+
chipToRemove = filterUIRow.componentInstance.expressionsList[2];
3302+
expect(() => { filterUIRow.componentInstance.onChipRemoved(null, chipToRemove); })
3303+
.not.toThrowError(/\'id\' of undefined/);
3304+
await wait(200);
3305+
fix.detectChanges();
3306+
3307+
verifyMultipleChipsVisibility(fix, [true, false]);
3308+
chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
3309+
expect(chips.length).toBe(2);
3310+
expect(grid.rowList.length).toBe(3);
3311+
}));
32493312
});
32503313

32513314
describe(null, () => {

0 commit comments

Comments
 (0)