Skip to content

Commit

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

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

Signed-off-by: Anas Shahid <[email protected]>
  • Loading branch information
Anas Shahid committed Jul 23, 2020
1 parent 9a61b77 commit 174b797
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 174b797

Please sign in to comment.