Fixes #3089: Dismiss pop-over on budget action (#3092)

* Fix no dismissal on budget action

* Add release notes file

* Correct tag

* Remove unnecessary callback

* Linting

* Apply same strategy on reportcomponents

* Rename to onMenuAction
This commit is contained in:
Fran González
2024-07-23 19:38:30 +02:00
committed by GitHub
parent 5c0bee6031
commit fe70ecb635
3 changed files with 24 additions and 11 deletions

View File

@@ -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={{
@@ -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 (
@@ -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>
@@ -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>

View File

@@ -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={{
@@ -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,
});
}}
@@ -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,
});
}}

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [sleepyfran]
---
Correctly dismiss pop-over when using the copy last month's budget feature