Skip to content

Commit

Permalink
Fixes #3089: Dismiss pop-over on budget action (#3092)
Browse files Browse the repository at this point in the history
* Fix no dismissal on budget action

* Add release notes file

* Correct tag

* Remove unnecessary callback

* Linting

* Apply same strategy on reportcomponents

* Rename to onMenuAction
  • Loading branch information
sleepyfran authored Jul 23, 2024
1 parent 5c0bee6 commit fe70ecb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ export const CategoryMonth = memo(function CategoryMonth({
const [balanceMenuOpen, setBalanceMenuOpen] = useState(false);
const triggerBalanceMenuRef = useRef(null);

const onMenuAction = (...args: Parameters<typeof onBudgetAction>) => {
onBudgetAction(...args);
setBalanceMenuOpen(false);
setMenuOpen(false);
};

return (
<View
style={{
Expand Down Expand Up @@ -225,10 +231,9 @@ export const CategoryMonth = memo(function CategoryMonth({
>
<BudgetMenu
onCopyLastMonthAverage={() => {
onBudgetAction?.(month, 'copy-single-last', {
onMenuAction(month, 'copy-single-last', {
category: category.id,
});
setMenuOpen(false);
}}
onSetMonthsAverage={numberOfMonths => {
if (
Expand All @@ -239,16 +244,14 @@ export const CategoryMonth = memo(function CategoryMonth({
return;
}

onBudgetAction?.(month, `set-single-${numberOfMonths}-avg`, {
onMenuAction(month, `set-single-${numberOfMonths}-avg`, {
category: category.id,
});
setMenuOpen(false);
}}
onApplyBudgetTemplate={() => {
onBudgetAction?.(month, 'apply-single-category-template', {
onMenuAction(month, 'apply-single-category-template', {
category: category.id,
});
setMenuOpen(false);
}}
/>
</Popover>
Expand Down Expand Up @@ -351,11 +354,10 @@ export const CategoryMonth = memo(function CategoryMonth({
<BalanceMenu
categoryId={category.id}
onCarryover={carryover => {
onBudgetAction?.(month, 'carryover', {
onMenuAction(month, 'carryover', {
category: category.id,
flag: carryover,
});
setBalanceMenuOpen(false);
}}
/>
</Popover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({
const [balanceMenuOpen, setBalanceMenuOpen] = useState(false);
const [hover, setHover] = useState(false);

const onMenuAction = (...args: Parameters<typeof onBudgetAction>) => {
onBudgetAction(...args);
setBudgetMenuOpen(false);
};

return (
<View
style={{
Expand Down Expand Up @@ -221,7 +226,7 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({
>
<BudgetMenu
onCopyLastMonthAverage={() => {
onBudgetAction?.(month, 'copy-single-last', {
onMenuAction(month, 'copy-single-last', {
category: category.id,
});
}}
Expand All @@ -234,12 +239,12 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({
return;
}

onBudgetAction?.(month, `set-single-${numberOfMonths}-avg`, {
onMenuAction(month, `set-single-${numberOfMonths}-avg`, {
category: category.id,
});
}}
onApplyBudgetTemplate={() => {
onBudgetAction?.(month, 'apply-single-category-template', {
onMenuAction(month, 'apply-single-category-template', {
category: category.id,
});
}}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3092.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [sleepyfran]
---

Correctly dismiss pop-over when using the copy last month's budget feature

0 comments on commit fe70ecb

Please sign in to comment.