Skip to content

Commit

Permalink
Fix warning modal not showing a second time. (#2956)
Browse files Browse the repository at this point in the history
* Fix warning modal not showing a second time.

* add release note
  • Loading branch information
psybers authored Jul 4, 2024
1 parent 31eb00a commit f18bce6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/desktop-client/src/components/Modals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export function Modals() {
<ConfirmTransactionEdit
key={name}
modalProps={modalProps}
onCancel={options.onCancel}
onConfirm={options.onConfirm}
confirmReason={options.confirmReason}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions packages/loot-core/src/client/state-types/modals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ type FinanceModals = {
'budget-list';
'confirm-transaction-edit': {
onConfirm: () => void;
onCancel?: () => void;
confirmReason: string;
};
'confirm-transaction-delete': {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2956.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [psybers]
---

Fix: Warning modal was not showing a second time.

0 comments on commit f18bce6

Please sign in to comment.