mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(ui): remove search term fetching indicator
Don't like this UI (even though I suggested it). No need to prevent the user from interacting with the search term field during fetching. Let's figure out a nicer way to present this in a followup.
This commit is contained in:
parent
face94ce33
commit
b1cc413bbd
@ -1,22 +1,16 @@
|
|||||||
import { IconButton, Input, InputGroup, InputRightElement, Spinner } from '@invoke-ai/ui-library';
|
import { IconButton, Input, InputGroup, InputRightElement } from '@invoke-ai/ui-library';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
import { selectListImagesQueryArgs } from 'features/gallery/store/gallerySelectors';
|
|
||||||
import { searchTermChanged } from 'features/gallery/store/gallerySlice';
|
import { searchTermChanged } from 'features/gallery/store/gallerySlice';
|
||||||
import { debounce } from 'lodash-es';
|
import { debounce } from 'lodash-es';
|
||||||
import type { ChangeEvent } from 'react';
|
import type { ChangeEvent } from 'react';
|
||||||
import { useCallback, useMemo, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { PiXBold } from 'react-icons/pi';
|
import { PiXBold } from 'react-icons/pi';
|
||||||
import { useListImagesQuery } from 'services/api/endpoints/images';
|
|
||||||
|
|
||||||
export const GallerySearch = () => {
|
export const GallerySearch = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { searchTerm } = useAppSelector((s) => s.gallery);
|
const { searchTerm } = useAppSelector((s) => s.gallery);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const queryArgs = useAppSelector(selectListImagesQueryArgs);
|
|
||||||
const { isFetching } = useListImagesQuery(queryArgs);
|
|
||||||
|
|
||||||
const [searchTermInput, setSearchTermInput] = useState(searchTerm);
|
const [searchTermInput, setSearchTermInput] = useState(searchTerm);
|
||||||
|
|
||||||
const debouncedSetSearchTerm = useMemo(() => {
|
const debouncedSetSearchTerm = useMemo(() => {
|
||||||
@ -45,24 +39,17 @@ export const GallerySearch = () => {
|
|||||||
value={searchTermInput}
|
value={searchTermInput}
|
||||||
onChange={handleChangeInput}
|
onChange={handleChangeInput}
|
||||||
data-testid="image-search-input"
|
data-testid="image-search-input"
|
||||||
disabled={isFetching}
|
|
||||||
/>
|
/>
|
||||||
{isFetching ? (
|
{searchTermInput.length && (
|
||||||
<InputRightElement h="full" pe={2}>
|
<InputRightElement h="full" pe={2}>
|
||||||
<Spinner size="sm" />
|
<IconButton
|
||||||
|
onClick={handleClearInput}
|
||||||
|
size="sm"
|
||||||
|
variant="link"
|
||||||
|
aria-label={t('boards.clearSearch')}
|
||||||
|
icon={<PiXBold />}
|
||||||
|
/>
|
||||||
</InputRightElement>
|
</InputRightElement>
|
||||||
) : (
|
|
||||||
searchTermInput.length && (
|
|
||||||
<InputRightElement h="full" pe={2}>
|
|
||||||
<IconButton
|
|
||||||
onClick={handleClearInput}
|
|
||||||
size="sm"
|
|
||||||
variant="link"
|
|
||||||
aria-label={t('boards.clearSearch')}
|
|
||||||
icon={<PiXBold />}
|
|
||||||
/>
|
|
||||||
</InputRightElement>
|
|
||||||
)
|
|
||||||
)}
|
)}
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user