mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-21 15:36:50 -05:00
fix(mobile): fix stale amounts in cover overspending modal (#6488)
* fix(mobile): close modals after cover overspending action When covering overspending on mobile, the category selection modal would remain open with stale data after the cover action completed. This fix dispatches closeModal() after the cover action to return the user to the budget view with the updated overspending banner. Fixes #6487 * fix: rename release notes file to match PR number * fix(mobile): fix stale overspending amounts in cover modal Fixes #6487
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
// @ts-strict-ignore
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { GridList, GridListItem } from 'react-aria-components';
|
||||
import { Trans, useTranslation } from 'react-i18next';
|
||||
|
||||
@@ -836,6 +842,9 @@ function OverspendingBanner({ month, onBudgetAction, budgetType, ...props }) {
|
||||
totalAmount: totalOverspending,
|
||||
} = useOverspentCategories({ month });
|
||||
|
||||
const amountsByCategoryRef = useRef(amountsByCategory);
|
||||
amountsByCategoryRef.current = amountsByCategory;
|
||||
|
||||
const categoryGroupsToShow = useMemo(
|
||||
() =>
|
||||
categoryGroups
|
||||
@@ -859,7 +868,7 @@ function OverspendingBanner({ month, onBudgetAction, budgetType, ...props }) {
|
||||
options: {
|
||||
title: category.name,
|
||||
month,
|
||||
amount: amountsByCategory.get(category.id),
|
||||
amount: amountsByCategoryRef.current.get(category.id),
|
||||
categoryId: category.id,
|
||||
onSubmit: (amount, fromCategoryId) => {
|
||||
onBudgetAction(month, 'cover-overspending', {
|
||||
@@ -887,7 +896,6 @@ function OverspendingBanner({ month, onBudgetAction, budgetType, ...props }) {
|
||||
);
|
||||
},
|
||||
[
|
||||
amountsByCategory,
|
||||
categoriesById,
|
||||
dispatch,
|
||||
month,
|
||||
|
||||
Reference in New Issue
Block a user