From f18bce60946a970199be8f5d4144033d355f81ce Mon Sep 17 00:00:00 2001
From: Robert Dyer <rdyer@unl.edu>
Date: Wed, 3 Jul 2024 20:13:57 -0500
Subject: [PATCH] Fix warning modal not showing a second time. (#2956)

* Fix warning modal not showing a second time.

* add release note
---
 packages/desktop-client/src/components/Modals.tsx      |  1 +
 .../src/components/modals/ConfirmTransactionEdit.tsx   | 10 +++++++++-
 .../src/components/transactions/TransactionsTable.jsx  |  5 ++++-
 packages/loot-core/src/client/state-types/modals.d.ts  |  1 +
 upcoming-release-notes/2956.md                         |  6 ++++++
 5 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 upcoming-release-notes/2956.md

diff --git a/packages/desktop-client/src/components/Modals.tsx b/packages/desktop-client/src/components/Modals.tsx
index 81f48f391..ac5b894b2 100644
--- a/packages/desktop-client/src/components/Modals.tsx
+++ b/packages/desktop-client/src/components/Modals.tsx
@@ -173,6 +173,7 @@ export function Modals() {
             <ConfirmTransactionEdit
               key={name}
               modalProps={modalProps}
+              onCancel={options.onCancel}
               onConfirm={options.onConfirm}
               confirmReason={options.confirmReason}
             />
diff --git a/packages/desktop-client/src/components/modals/ConfirmTransactionEdit.tsx b/packages/desktop-client/src/components/modals/ConfirmTransactionEdit.tsx
index 6fb4c8007..7ad0ff097 100644
--- a/packages/desktop-client/src/components/modals/ConfirmTransactionEdit.tsx
+++ b/packages/desktop-client/src/components/modals/ConfirmTransactionEdit.tsx
@@ -9,12 +9,14 @@ import { type CommonModalProps } from '../Modals';
 
 type ConfirmTransactionEditProps = {
   modalProps: Partial<CommonModalProps>;
+  onCancel?: () => void;
   onConfirm: () => void;
   confirmReason: string;
 };
 
 export function ConfirmTransactionEdit({
   modalProps,
+  onCancel,
   onConfirm,
   confirmReason,
 }: ConfirmTransactionEditProps) {
@@ -71,7 +73,13 @@ export function ConfirmTransactionEdit({
                 justifyContent: 'flex-end',
               }}
             >
-              <Button style={{ marginRight: 10 }} onClick={modalProps.onClose}>
+              <Button
+                style={{ marginRight: 10 }}
+                onClick={() => {
+                  modalProps.onClose();
+                  onCancel();
+                }}
+              >
                 Cancel
               </Button>
               <Button
diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.jsx b/packages/desktop-client/src/components/transactions/TransactionsTable.jsx
index b86092987..d3225f371 100644
--- a/packages/desktop-client/src/components/transactions/TransactionsTable.jsx
+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.jsx
@@ -730,7 +730,7 @@ const Transaction = memo(function Transaction({
 
   function onUpdate(name, value) {
     // Had some issues with this is called twice which is a problem now that we are showing a warning
-    // modal is the transaction is locked. I added a boolean to guard against showing the modal twice.
+    // modal if the transaction is locked. I added a boolean to guard against showing the modal twice.
     // I'm still not completely happy with how the cells update pre/post modal. Sometimes you have to
     // click off of the cell manually after confirming your change post modal for example. The last
     // row seems to have more issues than others but the combination of tab, return, and clicking out
@@ -749,6 +749,9 @@ const Transaction = memo(function Transaction({
           setShowReconciliationWarning(true);
           dispatch(
             pushModal('confirm-transaction-edit', {
+              onCancel: () => {
+                setShowReconciliationWarning(false);
+              },
               onConfirm: () => {
                 setShowReconciliationWarning(false);
                 onUpdateAfterConfirm(name, value);
diff --git a/packages/loot-core/src/client/state-types/modals.d.ts b/packages/loot-core/src/client/state-types/modals.d.ts
index f45233af1..3c091e1cc 100644
--- a/packages/loot-core/src/client/state-types/modals.d.ts
+++ b/packages/loot-core/src/client/state-types/modals.d.ts
@@ -252,6 +252,7 @@ type FinanceModals = {
   'budget-list';
   'confirm-transaction-edit': {
     onConfirm: () => void;
+    onCancel?: () => void;
     confirmReason: string;
   };
   'confirm-transaction-delete': {
diff --git a/upcoming-release-notes/2956.md b/upcoming-release-notes/2956.md
new file mode 100644
index 000000000..5ea7a72ab
--- /dev/null
+++ b/upcoming-release-notes/2956.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [psybers]
+---
+
+Fix: Warning modal was not showing a second time.
-- 
GitLab