Skip to content

Commit

Permalink
fix(stark-ui): generic-search trigger search on enter
Browse files Browse the repository at this point in the history
When press Enter key now the search is trigger

Braking Change:

The Components implementing
`StarkSearchFormComponent` must implement `submitEvent`
In the component template in the <form > tag
`(ngSubmit)="submitEvent.next()" and add `<button [hidden]="true" type="submit"></button>`

ISSUES CLOSED: #3116
  • Loading branch information
mhenkens committed Sep 15, 2022
1 parent 6734bcd commit 2412d6a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ export interface StarkSearchFormComponent<CriteriaType> {
* @param searchCriteria - The search criteria containing the reset values for the form fields
*/
resetSearchForm(searchCriteria: CriteriaType): void;

/**
* Emit the submit event when it on enter key
*/
submitEvent: EventEmitter<void>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ export class StarkGenericSearchComponent extends AbstractStarkUiComponent implem
if (!this.searchFormComponent) {
throw new Error("StarkGenericSearchComponent: the searchForm content child is required.");
}
this.searchFormComponent.submitEvent.subscribe(() => {
this.triggerSearch();
});
}

/**
Expand Down Expand Up @@ -536,6 +539,11 @@ export class StarkGenericSearchComponent extends AbstractStarkUiComponent implem
}
}

public handleKeyUpEnter(event: any): void {
console.log(event);
this.triggerSearch();
}

/**
* Hide the search form and emit a boolean through formVisibilityChanged event emitter that indicates if the search is displayed
*/
Expand Down

0 comments on commit 2412d6a

Please sign in to comment.