Shun Miyazawa 2 سال پیش
والد
کامیت
c972a5f1e9
1فایلهای تغییر یافته به همراه6 افزوده شده و 5 حذف شده
  1. 6 5
      apps/app/src/features/search/client/components/SearchResultMenuItem.tsx

+ 6 - 5
apps/app/src/features/search/client/components/SearchResultMenuItem.tsx

@@ -23,11 +23,12 @@ export const SearchResultMenuItem = (props: Props): JSX.Element => {
 
   const { data: searchResult, isLoading } = useSWRxSearch(isEmptyKeyword ? null : debouncedKeyword, null, { limit: 10 });
 
-  const getFiexdIndex = useCallback((index: number | null) => {
-    if (index == null) {
-      return -1;
-    }
-
+  /**
+   *  SearchMenu is a combination of a list of SearchMethodMenuItem and SearchResultMenuItem (this component).
+   *  If no keywords are entered into SearchForm, SearchMethodMenuItem returns a single item. Conversely, when keywords are entered, three items are returned.
+   *  The above means that the starting index value changes depending on whether or not input is received.
+   */
+  const getFiexdIndex = useCallback((index: number) => {
     return (isEmptyKeyword ? 1 : 3) + index;
   }, [isEmptyKeyword]);