Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Added searchClear emitter to Search Component (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-TrevorBurch authored and Blackbaud-SteveBrush committed Aug 25, 2017
1 parent cb8e6d2 commit 63d58ac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/components/search/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
propertyName="searchChange">
Fires when the search text is changed.
</sky-demo-page-property>
<sky-demo-page-property
propertyName="searchClear">
Fires when the search text is cleared.
</sky-demo-page-property>
</sky-demo-page-properties>
<sky-demo-page-example>
<sky-search-demo></sky-search-demo>
Expand Down
10 changes: 10 additions & 0 deletions src/modules/search/search.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,16 @@ describe('Search component', () => {
expect(component.lastSearchTextChanged).toBe('');
});

it('should emit the cleared event when clear button is clicked', () => {
spyOn(component.searchComponent.searchClear, 'emit').and.callThrough();
setInput('applied text');
triggerApplyButton();
triggerClearButton();

expect(element.query(By.css('.sky-input-group-clear')).nativeElement).not.toBeVisible();
expect(component.searchComponent.searchClear.emit).toHaveBeenCalled();
});

it('should apply the correct focus class', () => {
triggerFocus();
let containerEl = element.query(By.css('.sky-search-input-container.sky-search-input-focused'));
Expand Down
5 changes: 5 additions & 0 deletions src/modules/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export class SkySearchComponent implements OnDestroy, OnInit, OnChanges {
@Output()
public searchChange = new EventEmitter<string>();

@Output()
public searchClear = new EventEmitter<void>();

@Input()
public searchText: string;

Expand Down Expand Up @@ -165,6 +168,8 @@ export class SkySearchComponent implements OnDestroy, OnInit, OnChanges {
this.searchChange.emit(this.searchText);

this.searchApply.emit(this.searchText);

this.searchClear.emit();
}

public enterPress(event: KeyboardEvent, searchText: string) {
Expand Down

0 comments on commit 63d58ac

Please sign in to comment.