change(ui): debounce the highlights search
This commit is contained in:
parent
0d68fcc428
commit
e325eee47e
2 changed files with 8 additions and 3 deletions
|
|
@ -42,13 +42,18 @@ function HighlightsList() {
|
|||
retry: 3
|
||||
});
|
||||
const { total, notes } = data;
|
||||
const debounceTimeout = React.useRef(0);
|
||||
|
||||
const onSearch = (value: string) => {
|
||||
notesStore.setQuery(value);
|
||||
};
|
||||
|
||||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
notesStore.setQuery(e.target.value);
|
||||
const value = e.target.value;
|
||||
if (debounceTimeout.current) clearTimeout(debounceTimeout.current);
|
||||
debounceTimeout.current = window.setTimeout(() => {
|
||||
notesStore.setQuery(value);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
const toggleTag = (tag?: iTag) => {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ function HighlightsListHeader({
|
|||
</div>
|
||||
<div className="w-56">
|
||||
<Input.Search
|
||||
value={query}
|
||||
defaultValue={query}
|
||||
allowClear
|
||||
name="spot-search"
|
||||
placeholder="Filter by title"
|
||||
|
|
@ -93,4 +93,4 @@ function HighlightsListHeader({
|
|||
)
|
||||
}
|
||||
|
||||
export default HighlightsListHeader
|
||||
export default HighlightsListHeader
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue