This is an automated email from the ASF dual-hosted git repository.

mintsweet pushed a commit to branch fix-bugs
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit f0027ccf403cb86ac1c066747277a4916c2d5b06
Author: mintsweet <[email protected]>
AuthorDate: Thu Dec 28 19:33:04 2023 +1300

    fix(config-ui): menu selected error
---
 config-ui/src/routes/layout/layout.tsx | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/config-ui/src/routes/layout/layout.tsx 
b/config-ui/src/routes/layout/layout.tsx
index 92155d7e7..6bcd62ea8 100644
--- a/config-ui/src/routes/layout/layout.tsx
+++ b/config-ui/src/routes/layout/layout.tsx
@@ -62,7 +62,16 @@ export const Layout = () => {
   }, []);
 
   useEffect(() => {
-    setSelectedKeys([pathname]);
+    const selectedKeys = pathname.split('/').reduce((acc, cur, i, arr) => {
+      if (i === 0) {
+        acc.push('/');
+        return acc;
+      } else {
+        acc.push(`${arr.slice(0, i + 1).join('/')}`);
+        return acc;
+      }
+    }, [] as string[]);
+    setSelectedKeys(selectedKeys);
   }, [pathname]);
 
   if (['idle', 'loading'].includes(status)) {

Reply via email to