aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/search
diff options
context:
space:
mode:
authoralyssaf16 <alyssa_feinberg@brown.edu>2024-03-12 16:14:58 -0400
committeralyssaf16 <alyssa_feinberg@brown.edu>2024-03-12 16:14:58 -0400
commit2d9763a63a661420ae0ffa8b4436b29ed717b90b (patch)
tree4c3623c87a6e4e184d06579569fb239cfbad3dc1 /src/client/views/search
parentecfb0d119e08a101cd8d18e8a90d31995f71eeec (diff)
parent641220e9cd9626af182118f84f8f775d7638cc67 (diff)
Merge branch 'master' into alyssa-starter
Diffstat (limited to 'src/client/views/search')
-rw-r--r--src/client/views/search/SearchBox.tsx10
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();
}}