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:
Faizan Qureshi
2025-12-28 02:32:51 +05:30
committed by GitHub
parent 45fa1aaf02
commit dfc56b879f
2 changed files with 17 additions and 3 deletions

View File

@@ -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,

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [Faizanq]
---
Fix mobile cover overspending amount not updating correctly when selecting categories