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

consider disableIncrementalSearch

Yuki Takei 4 лет назад
Родитель
Сommit
864976da92
1 измененных файлов с 14 добавлено и 11 удалено
  1. 14 11
      packages/app/src/components/SearchTypeahead.tsx

+ 14 - 11
packages/app/src/components/SearchTypeahead.tsx

@@ -135,23 +135,26 @@ const SearchTypeahead: ForwardRefRenderFunction<IFocusable, Props> = (props: Pro
   }, []);
 
   const renderMenu = useCallback((options: IPageWithMeta<IPageSearchMeta>[], menuProps) => {
-    const isEmptyInput = input == null || input.length === 0;
-
     if (!isForcused) {
       return <></>;
     }
 
+    const isEmptyInput = input == null || input.length === 0;
     if (isEmptyInput) {
-      if (helpElement != null) {
-        return (
-          <Menu {...menuProps}>
-            <div className="p-3">
-              {helpElement}
-            </div>
-          </Menu>
-        );
+      if (helpElement == null) {
+        return <></>;
       }
 
+      return (
+        <Menu {...menuProps}>
+          <div className="p-3">
+            {helpElement}
+          </div>
+        </Menu>
+      );
+    }
+
+    if (disableIncrementalSearch) {
       return <></>;
     }
 
@@ -168,7 +171,7 @@ const SearchTypeahead: ForwardRefRenderFunction<IFocusable, Props> = (props: Pro
         ))}
       </Menu>
     );
-  }, [helpElement, input, isForcused]);
+  }, [disableIncrementalSearch, helpElement, input, isForcused]);
 
   const isLoading = searchResult == null && searchError == null;
   const isOpenAlways = helpElement != null;