Skip to content

Commit

Permalink
[DOP-21927] fix after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Zabilsya committed Jan 16, 2025
1 parent 07bde3d commit 9fe6120
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/shared/ui/ManagedSelect/ManagedSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export const ManagedSelect = <T, V extends DefaultOptionType['value']>({
onSearch,
...props
}: ManagedSelectProps<T, V>) => {
const [touched, setTouched] = useState(false);
const [hasTouched, setTouched] = useState(false);

const { searchValue, setSearchValue, handleSearch } = useSearch({ onSearch });

const { data, hasNextPage, fetchNextPage, isLoading, isFetching } = useGetList({
queryKey,
queryFunction,
touched,
hasTouched,
searchValue,
});

Expand Down
2 changes: 1 addition & 1 deletion src/shared/ui/ManagedSelect/hooks/useGetList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { QueryKey } from '@tanstack/react-query';
*/
export interface UseGetListProps<T> {
/** Select was in focus one time at least */
touched: boolean;
hasTouched: boolean;
/** Query keys for requests cache of entity list data */
queryKey: QueryKey;
/** Function for request entity list data */
Expand Down
4 changes: 2 additions & 2 deletions src/shared/ui/ManagedSelect/hooks/useGetList/useGetList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PAGE_DEFAULT, PAGE_SIZE_DEFAULT, REQUEST_FIRST_PAGE_DELAY } from '../..
import { UseGetListProps } from './types';

/** Hook for getting option list data for Select */
export const useGetList = <T>({ queryKey, queryFunction, searchValue, touched }: UseGetListProps<T>) => {
export const useGetList = <T>({ queryKey, queryFunction, searchValue, hasTouched }: UseGetListProps<T>) => {
return useInfiniteRequest<T>({
queryKey: [...queryKey, searchValue],
queryFn: async ({ pageParam }) => {
Expand All @@ -18,6 +18,6 @@ export const useGetList = <T>({ queryKey, queryFunction, searchValue, touched }:
},
initialPageParam: { page: PAGE_DEFAULT, page_size: PAGE_SIZE_DEFAULT },
// Show first page of options when user touches select
enabled: touched,
enabled: hasTouched,
});
};

0 comments on commit 9fe6120

Please sign in to comment.