Skip to content

A local-first personal finance app

Close modals on route change (#1613)

Joel Jeremy Marquez05e582793d37
diff --git a/packages/desktop-client/src/components/Modals.tsx b/packages/desktop-client/src/components/Modals.tsx
index 9524ef06f6..7299f17abe 100644
--- a/packages/desktop-client/src/components/Modals.tsx
+++ b/packages/desktop-client/src/components/Modals.tsx
@@ -1,5 +1,6 @@
-import React from 'react';
+import React, { useEffect } from 'react';
import { useSelector } from 'react-redux';
+import { useLocation } from 'react-router-dom';
import { send } from 'loot-core/src/platform/client/fetch';
@@ -39,6 +40,13 @@ export default function Modals() {
state => state.prefs.local && state.prefs.local.id,
);
const actions = useActions();
+ const location = useLocation();
+
+ useEffect(() => {
+ if (modalStack.length > 0) {
+ actions.closeModal();
+ }
+ }, [location]);
const syncServerStatus = useSyncServerStatus();
diff --git a/upcoming-release-notes/1613.md b/upcoming-release-notes/1613.md
new file mode 100644
index 0000000000..3276cdedcc
--- /dev/null
+++ b/upcoming-release-notes/1613.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [joel-jeremy]
+---
+
+Close open modals when navigating to a different URL.