diff --git a/packages/desktop-client/src/components/Modals.tsx b/packages/desktop-client/src/components/Modals.tsx index 61d60ba62a..f3ba35003e 100644 --- a/packages/desktop-client/src/components/Modals.tsx +++ b/packages/desktop-client/src/components/Modals.tsx @@ -1,5 +1,5 @@ // @ts-strict-ignore -import React, { Fragment, useEffect } from 'react'; +import React, { Fragment, useEffect, useEffectEvent } from 'react'; import { useLocation } from 'react-router'; import { send } from 'loot-core/platform/client/fetch'; @@ -89,12 +89,15 @@ export function Modals() { const { modalStack } = useModalState(); const [budgetId] = useMetadataPref('id'); - useEffect(() => { + const onCloseModal = useEffectEvent(() => { if (modalStack.length > 0) { dispatch(closeModal()); } - // oxlint-disable-next-line react/exhaustive-deps - }, [dispatch, location]); + }); + + useEffect(() => { + onCloseModal(); + }, [location]); const modals = modalStack .map((modal, idx) => { diff --git a/upcoming-release-notes/6862.md b/upcoming-release-notes/6862.md new file mode 100644 index 0000000000..e24e9e9526 --- /dev/null +++ b/upcoming-release-notes/6862.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [joel-jeremy] +--- + +Refactor modal closing behavior to improve code clarity and eliminate eslint disable patterns.