Skip to content

Commit d2b010b

Browse files
Merge pull request #5515 from IgniteUI/astaev/issue5304-8.1.x
fix(filtering): Scroll chips before remove #5304
2 parents ad365f4 + 6f5b8dd commit d2b010b

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
@@ -753,7 +753,7 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
753753
const containerRect = this.container.nativeElement.getBoundingClientRect();
754754

755755
for (let index = 0; index < chipAraeChildren.length; index++) {
756-
if (Math.ceil(chipAraeChildren[index].getBoundingClientRect().left) < Math.ceil(containerRect.left)) {
756+
if (Math.ceil(chipAraeChildren[index].getBoundingClientRect().right) < Math.ceil(containerRect.left)) {
757757
count++;
758758
}
759759
}

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

32543317
describe(null, () => {

0 commit comments

Comments
 (0)