Skip to content

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

Fix redirect when opening extension popup externally (#541)

Leendert de Borst42573bf1fca0
diff --git a/browser-extensions/chrome/src/app/App.tsx b/browser-extensions/chrome/src/app/App.tsx
index 2d908c56e..71532b4ab 100644
--- a/browser-extensions/chrome/src/app/App.tsx
+++ b/browser-extensions/chrome/src/app/App.tsx
@@ -33,7 +33,6 @@ const App: React.FC = () => {
const authContext = useAuth();
const { isInitialLoading } = useLoading();
const [isLoading, setIsLoading] = useMinDurationLoading(true, 150);
- const [isUserMenuOpen, setIsUserMenuOpen] = useState(false);
const [message, setMessage] = useState<string | null>(null);
// Add these route configurations
@@ -74,8 +73,6 @@ const App: React.FC = () => {
<GlobalStateChangeHandler />
<Header
- toggleUserMenu={() => setIsUserMenuOpen(!isUserMenuOpen)}
- isUserMenuOpen={isUserMenuOpen}
routes={routes}
/>
diff --git a/browser-extensions/chrome/src/app/components/GlobalStateChangeHandler.tsx b/browser-extensions/chrome/src/app/components/GlobalStateChangeHandler.tsx
index 614f51559..016d3749c 100644
--- a/browser-extensions/chrome/src/app/components/GlobalStateChangeHandler.tsx
+++ b/browser-extensions/chrome/src/app/components/GlobalStateChangeHandler.tsx
@@ -10,6 +10,7 @@ const GlobalStateChangeHandler: React.FC = () => {
const authContext = useAuth();
const navigate = useNavigate();
const lastLoginState = useRef(authContext.isLoggedIn);
+ const initialRender = useRef(true);
/**
* Listen for auth logged in changes and redirect to home page if logged in state changes to handle logins and logouts.
@@ -18,6 +19,17 @@ const GlobalStateChangeHandler: React.FC = () => {
// Only navigate when auth state is different from the last state we acted on.
if (lastLoginState.current !== authContext.isLoggedIn) {
lastLoginState.current = authContext.isLoggedIn;
+
+ /**
+ * Skip the first auth state change to avoid redirecting when popup opens for the first time
+ * which already causes the auth state to change from false to true.
+ */
+ if (initialRender.current) {
+ initialRender.current = false;
+ return;
+ }
+
+ // Redirect to home page if logged in state changes.
navigate('/');
}
}, [authContext.isLoggedIn]); // eslint-disable-line react-hooks/exhaustive-deps