Skip to content

Commit ce96517

Browse files
committed
chore(*): fix unit test and change when cancel chip click is set to false #6594
1 parent abee7e2 commit ce96517

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,10 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
544544

545545
public onChipClick(args, item: ExpressionUI) {
546546
if (this._cancelChipClick) {
547+
this._cancelChipClick = false;
547548
return;
548549
}
549550

550-
this._cancelChipClick = false;
551-
552551
this.expressionsList.forEach(ex => ex.isSelected = false);
553552

554553
this.toggleChip(item);

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,8 +3462,8 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
34623462
// Click the today date.
34633463
const outlet = document.getElementsByClassName('igx-grid__outlet')[0];
34643464
let calendar = outlet.getElementsByClassName('igx-calendar')[0];
3465-
const todayDayItem: HTMLElement = calendar.querySelector('.igx-calendar__date--current');
3466-
todayDayItem.click();
3465+
const todayDayItem = calendar.querySelector('.igx-calendar__date--current');
3466+
clickHtmlElemAndBlur(todayDayItem, inputDebugElement);
34673467
tick(100);
34683468
fix.detectChanges();
34693469

@@ -3474,9 +3474,10 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
34743474
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBeTruthy('initial chip is committed');
34753475

34763476
// Focus out
3477-
clickElemAndBlur(dateFilterCellChip, inputDebugElement);
3477+
clickHtmlElemAndBlur(chip, inputDebugElement);
34783478
tick(200);
34793479
fix.detectChanges();
3480+
34803481
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBeFalsy('initial chip is not committed');
34813482
expect(input.value).toBeFalsy('initial input value is present and not committed');
34823483

@@ -3505,21 +3506,20 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
35053506

35063507
// Select the first day
35073508
const firstDayItem: HTMLElement = calendar.querySelector('.igx-calendar__date');
3508-
firstDayItem.click();
3509+
clickHtmlElemAndBlur(firstDayItem, inputDebugElement);
35093510
tick(100);
35103511
fix.detectChanges();
35113512

35123513
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBeTruthy('chip is committed');
35133514

35143515
// Focus out
3515-
clickElemAndBlur(dateFilterCellChip, inputDebugElement);
3516+
clickHtmlElemAndBlur(chip, inputDebugElement);
35163517
tick(200);
35173518
fix.detectChanges();
35183519
expect(chipDiv.classList.contains('igx-chip__item--selected')).toBe(false, 'chip is selected');
35193520

35203521
// Check if we still have only one committed chip
3521-
const activeFiltersArea = filteringRow.query(By.css('.igx-grid__filtering-row-main'));
3522-
const activeFilterChip: IgxChipComponent = activeFiltersArea.query(By.directive(IgxChipComponent)).componentInstance;
3522+
const activeFilterChip: IgxChipComponent = filteringRow.query(By.directive(IgxChipComponent)).componentInstance;
35233523
const chipsLength = GridFunctions.getAllFilterConditionChips(fix).length;
35243524

35253525
expect(chipsLength).toBe(1, 'there is more than one chip');
@@ -6552,3 +6552,13 @@ function clickElemAndBlur(clickElem, blurElem) {
65526552
UIInteractions.simulatePointerEvent('pointerup', clickElem.nativeElement, elementRect.left, elementRect.top);
65536553
UIInteractions.simulateMouseEvent('click', clickElem.nativeElement, 10, 10);
65546554
}
6555+
6556+
function clickHtmlElemAndBlur(clickElem, blurElem) {
6557+
const elementRect = clickElem.getBoundingClientRect();
6558+
UIInteractions.simulatePointerEvent('pointerdown', clickElem, elementRect.left, elementRect.top);
6559+
blurElem.nativeElement.blur();
6560+
clickElem.focus();
6561+
blurElem.nativeElement.dispatchEvent(new FocusEvent('focusout', { bubbles: true }));
6562+
UIInteractions.simulatePointerEvent('pointerup', clickElem, elementRect.left, elementRect.top);
6563+
UIInteractions.simulateMouseEvent('click', clickElem, 10, 10);
6564+
}

0 commit comments

Comments
 (0)