Skip to content

Commit

Permalink
[SIW]: Run search on input change
Browse files Browse the repository at this point in the history
Fixes: #7346

Runs a search query only when there is a change in the input field

Signed-off-by: Anas Shahid <muhammad.shahid@ericsson.com>
  • Loading branch information
Anas Shahid authored and vince-fugnitto committed Jul 29, 2020
1 parent 8969486 commit 77fa067
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,13 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge
protected readonly search = (e: React.KeyboardEvent) => this.doSearch(e);
protected doSearch(e: React.KeyboardEvent): void {
if (e.target) {
const searchValue = (e.target as HTMLInputElement).value;
if (Key.ARROW_DOWN.keyCode === e.keyCode) {
this.resultTreeWidget.focusFirstResult();
} else if (this.searchTerm === searchValue && Key.ENTER.keyCode !== e.keyCode) {
return;
} else {
this.searchTerm = (e.target as HTMLInputElement).value;
this.searchTerm = searchValue;
this.resultTreeWidget.search(this.searchTerm, (this.searchInWorkspaceOptions || {}));
}
}
Expand Down

0 comments on commit 77fa067

Please sign in to comment.