Browse Source

fix nav menu switch to overview on search page when refresh

tumao 4 years ago
parent
commit
2884fe14fe
2 changed files with 11 additions and 8 deletions
  1. 11 7
      client/src/components/layout/Layout.tsx
  2. 0 1
      client/src/utils/search.ts

+ 11 - 7
client/src/components/layout/Layout.tsx

@@ -46,13 +46,17 @@ const Layout = (props: any) => {
   const { t: navTrans } = useTranslation('nav');
   const classes = useStyles();
   const location = useLocation();
-  const defaultActive = useMemo(
-    () =>
-      location.pathname.includes('collection')
-        ? navTrans('collection')
-        : navTrans('overview'),
-    [location, navTrans]
-  );
+  const defaultActive = useMemo(() => {
+    if (location.pathname.includes('collection')) {
+      return navTrans('collection');
+    }
+
+    if (location.pathname.includes('search')) {
+      return navTrans('search');
+    }
+
+    return navTrans('overview');
+  }, [location, navTrans]);
 
   const menuItems: NavMenuItem[] = [
     {

+ 0 - 1
client/src/utils/search.ts

@@ -29,7 +29,6 @@ export const transferSearchResult = (
 /**
  * function to get EmbeddingType
  * @param fieldType only vector type fields: 'BinaryVector' or 'FloatVector'
- * @returns 'FLOAT_INDEX' or 'BINARY_INDEX'
  */
 export const getEmbeddingType = (
   fieldType: DataType