V2Wizard: Debounce package search
This debounces package search so it doesn't overwhelm content API with two requests for every character.
This commit is contained in:
parent
575fe0a91f
commit
b80d0fa3ae
1 changed files with 5 additions and 1 deletions
|
|
@ -32,9 +32,11 @@ import {
|
|||
SearchIcon,
|
||||
} from '@patternfly/react-icons';
|
||||
import { Table, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table';
|
||||
import { debounce } from 'lodash';
|
||||
import { useDispatch } from 'react-redux';
|
||||
|
||||
import {
|
||||
DEBOUNCED_SEARCH_WAIT_TIME,
|
||||
EPEL_8_REPO_DEFINITION,
|
||||
EPEL_9_REPO_DEFINITION,
|
||||
RH_ICON_SIZE,
|
||||
|
|
@ -534,6 +536,8 @@ const Packages = () => {
|
|||
setSearchTerm(selection);
|
||||
};
|
||||
|
||||
const debounceOnChange = debounce(handleSearch, DEBOUNCED_SEARCH_WAIT_TIME);
|
||||
|
||||
const handleSelect = (
|
||||
pkg: IBPackageWithRepositoryInfo,
|
||||
_: number,
|
||||
|
|
@ -735,7 +739,7 @@ const Packages = () => {
|
|||
aria-label="Search packages"
|
||||
data-testid="packages-search-input"
|
||||
value={searchTerm}
|
||||
onChange={handleSearch}
|
||||
onChange={debounceOnChange}
|
||||
/>
|
||||
</ToolbarItem>
|
||||
<ToolbarItem>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue