Skip to content

Commit 9b59b4d

Browse files
authored
feat(simple-combo): hide clear button immediately when clearing selection by typing (#12556)
* feat(simple-combo): hide clear btn if no selection * feat(simple-combo): use selection.length instead
1 parent 9e18ae5 commit 9b59b4d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<ng-container ngProjectAs="igx-suffix">
2121
<ng-content select="igx-suffix"></ng-content>
2222
</ng-container>
23-
<igx-suffix *ngIf="comboInput.value.length" aria-label="Clear Selection" class="igx-combo__clear-button"
23+
<igx-suffix *ngIf="selection.length" aria-label="Clear Selection" class="igx-combo__clear-button"
2424
(click)="handleClear($event)">
2525
<ng-container *ngIf="clearIconTemplate">
2626
<ng-container *ngTemplateOutlet="clearIconTemplate"></ng-container>

projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ describe('IgxSimpleCombo', () => {
12861286
fixture.detectChanges();
12871287
combo = fixture.componentInstance.combo;
12881288

1289-
const toggleIcon = fixture.debugElement.query(By.directive(IgxIconComponent));
1289+
const toggleIcon = fixture.debugElement.query(By.css(`.${CSS_CLASS_TOGGLEBUTTON}`));
12901290
expect(toggleIcon).toBeDefined();
12911291

12921292
expect(toggleIcon.nativeElement.textContent).toBe('search');
@@ -1311,12 +1311,19 @@ describe('IgxSimpleCombo', () => {
13111311

13121312
expect(combo.selection.length).toEqual(1);
13131313

1314+
let clearButton = fixture.debugElement.query(By.css(`.${CSS_CLASS_CLEARBUTTON}`));
1315+
expect(clearButton).not.toBeNull();
1316+
13141317
input.triggerEventHandler('focus', {});
13151318
fixture.detectChanges();
13161319

13171320
UIInteractions.simulateTyping('L', input, 9, 10);
13181321
fixture.detectChanges();
13191322
expect(combo.selection.length).toEqual(0);
1323+
1324+
//should hide the clear button immediately when clearing the selection by typing
1325+
clearButton = fixture.debugElement.query(By.css(`.${CSS_CLASS_CLEARBUTTON}`));
1326+
expect(clearButton).toBeNull();
13201327
});
13211328
});
13221329

0 commit comments

Comments
 (0)