Просмотр исходного кода

Merge pull request #7990 from weseek/fix/autocomplete

fix: "Searching..." label appearing unnecessarily
Yuki Takei 2 лет назад
Родитель
Сommit
2b896f3c39
2 измененных файлов с 2 добавлено и 2 удалено
  1. 1 2
      apps/app/src/components/SearchTypeahead.tsx
  2. 1 0
      apps/app/src/stores/search.tsx

+ 1 - 2
apps/app/src/components/SearchTypeahead.tsx

@@ -65,7 +65,7 @@ const SearchTypeahead: ForwardRefRenderFunction<IFocusable, Props> = (props: Pro
   const [searchKeyword, setSearchKeyword] = useState('');
   const [searchKeyword, setSearchKeyword] = useState('');
   const [isForcused, setFocused] = useState(false);
   const [isForcused, setFocused] = useState(false);
 
 
-  const { data: searchResult, error: searchError } = useSWRxSearch(
+  const { data: searchResult, error: searchError, isLoading } = useSWRxSearch(
     disableIncrementalSearch ? null : searchKeyword,
     disableIncrementalSearch ? null : searchKeyword,
     null,
     null,
     { limit: 10 },
     { limit: 10 },
@@ -220,7 +220,6 @@ const SearchTypeahead: ForwardRefRenderFunction<IFocusable, Props> = (props: Pro
     );
     );
   }, [disableIncrementalSearch, helpElement, input, isForcused]);
   }, [disableIncrementalSearch, helpElement, input, isForcused]);
 
 
-  const isLoading = searchResult !== undefined && searchError == null;
   const isOpenAlways = helpElement != null;
   const isOpenAlways = helpElement != null;
 
 
   return (
   return (

+ 1 - 0
apps/app/src/stores/search.tsx

@@ -86,6 +86,7 @@ export const useSWRxSearch = (
       ).then(result => result as IFormattedSearchResult);
       ).then(result => result as IFormattedSearchResult);
     },
     },
     {
     {
+      keepPreviousData: true,
       revalidateOnFocus: false,
       revalidateOnFocus: false,
     },
     },
   );
   );