Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update bottomnav to update selected item on path change (#647)

Leendert de Borstceaa7731fe99
diff --git a/browser-extensions/chrome/src/app/components/Layout/BottomNav.tsx b/browser-extensions/chrome/src/app/components/Layout/BottomNav.tsx
index 4dcad8cbd..3404ca086 100644
--- a/browser-extensions/chrome/src/app/components/Layout/BottomNav.tsx
+++ b/browser-extensions/chrome/src/app/components/Layout/BottomNav.tsx
@@ -1,5 +1,5 @@
-import React, { useState } from 'react';
-import { useNavigate } from 'react-router-dom';
+import React, { useState, useEffect } from 'react';
+import { useNavigate, useLocation } from 'react-router-dom';
import { useAuth } from '../../context/AuthContext';
import { useDb } from '../../context/DbContext';
@@ -10,8 +10,17 @@ const BottomNav: React.FC = () => {
const authContext = useAuth();
const dbContext = useDb();
const navigate = useNavigate();
+ const location = useLocation();
const [currentTab, setCurrentTab] = useState<'credentials' | 'emails' | 'settings'>('credentials');
+ // Add effect to update currentTab based on route
+ useEffect(() => {
+ const path = location.pathname.substring(1) as 'credentials' | 'emails' | 'settings';
+ if (['credentials', 'emails', 'settings'].includes(path)) {
+ setCurrentTab(path);
+ }
+ }, [location]);
+
/**
* Handle tab change.
*/
diff --git a/browser-extensions/chrome/src/app/components/Layout/Header.tsx b/browser-extensions/chrome/src/app/components/Layout/Header.tsx
index 34dc21202..588676a8d 100644
--- a/browser-extensions/chrome/src/app/components/Layout/Header.tsx
+++ b/browser-extensions/chrome/src/app/components/Layout/Header.tsx
@@ -52,6 +52,19 @@ const Header: React.FC<HeaderProps> = ({
navigate('/auth-settings');
};
+ /**
+ * Handle logo click.
+ */
+ const logoClick = () : void => {
+ // If logged in, navigate to credentials.
+ if (authContext.isLoggedIn) {
+ navigate('/credentials');
+ } else {
+ // If not logged in, navigate to index.
+ navigate('/');
+ }
+ };
+
return (
<header className="fixed z-30 w-full bg-white border-b border-gray-200 dark:bg-gray-800 dark:border-gray-700">
<div className="flex items-center h-16 px-4">
@@ -74,9 +87,14 @@ const Header: React.FC<HeaderProps> = ({
</button>
) : (
<div className="flex items-center">
- <img src="/assets/images/logo.svg" alt="AliasVault" className="h-8 w-8 mr-2" />
- <h1 className="text-gray-900 dark:text-white text-xl font-bold">AliasVault</h1>
- <span className="text-primary-500 text-[10px] ml-1 font-normal">BETA</span>
+ <button
+ onClick={() => logoClick()}
+ className="flex items-center hover:opacity-80 transition-opacity"
+ >
+ <img src="/assets/images/logo.svg" alt="AliasVault" className="h-8 w-8 mr-2" />
+ <h1 className="text-gray-900 dark:text-white text-xl font-bold">AliasVault</h1>
+ <span className="text-primary-500 text-[10px] ml-1 font-normal">BETA</span>
+ </button>
</div>
)}