diff options
| author | eleanor-park <eleanor_park@brown.edu> | 2024-04-14 14:27:43 -0400 |
|---|---|---|
| committer | eleanor-park <eleanor_park@brown.edu> | 2024-04-14 14:27:43 -0400 |
| commit | 15e40cd865474f524c8e35f9352fc40d4b515ab3 (patch) | |
| tree | 4ba71fafec248b22226157908b9fb578e4529df6 /src/client/views/search | |
| parent | d938cd08650279f5c7894793d5fd78ec4068694c (diff) | |
| parent | 36d18da80e5e5e1c6cae0dc21c1677a7ab9c1d77 (diff) | |
Merge branch 'eleanor-starter' of https://github.com/brown-dash/Dash-Web into eleanor-starter
Diffstat (limited to 'src/client/views/search')
| -rw-r--r-- | src/client/views/search/SearchBox.tsx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 0b664beaa..9f153e86d 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -88,9 +88,11 @@ export class SearchBox extends ViewBoxBaseComponent<SearchBoxProps>() { * (Note: There is no longer a need to press enter to submit a search. Any update to the input * causes a search to be submitted automatically.) */ + _timeout: any = undefined; onInputChange = action((e: React.ChangeEvent<HTMLInputElement>) => { this._searchString = e.target.value; - this.submitSearch(); + this._timeout && clearTimeout(this._timeout); + this._timeout = setTimeout(() => this.submitSearch(), 300); }); /** @@ -334,6 +336,8 @@ export class SearchBox extends ViewBoxBaseComponent<SearchBoxProps>() { * brushes and highlights. All search matches are cleared as well. */ resetSearch = action(() => { + this._timeout && clearTimeout(this._timeout); + this._timeout = undefined; this._results.forEach((_, doc) => { DocumentManager.Instance.getFirstDocumentView(doc)?.ComponentView?.search?.('', undefined, true); Doc.UnBrushDoc(doc); @@ -436,10 +440,10 @@ export class SearchBox extends ViewBoxBaseComponent<SearchBoxProps>() { </select> )} <input - defaultValue={''} + defaultValue="" autoComplete="off" onChange={this.onInputChange} - onKeyPress={e => { + onKeyDown={e => { e.key === 'Enter' ? this.submitSearch() : null; e.stopPropagation(); }} |
