Skip to content

Fix custom report editor retaining unsaved settings#7356

Open
tmchow wants to merge 2 commits intoactualbudget:masterfrom
tmchow:fix/7332-clear-unsaved-report-state
Open

Fix custom report editor retaining unsaved settings#7356
tmchow wants to merge 2 commits intoactualbudget:masterfrom
tmchow:fix/7332-clear-unsaved-report-state

Conversation

@tmchow
Copy link
Copy Markdown

@tmchow tmchow commented Apr 2, 2026

Summary

Custom report settings (like graph type) were persisting between visits even when not saved. Changed the session storage clear condition so it fires whenever the stored URL differs from the current path, not just when coming from /reports.

Root cause

The URL tracking in CustomReportInner stores the current path in sessionStorage.url. The clear condition only checked if (['/reports'].includes(prevUrl)), but since this tracking code runs inside the report component (not the dashboard), the stored URL always pointed to a report path, never /reports. So the clear never fired when revisiting the same report.

Changes

One-line change in CustomReport.tsx (line 186): replaced the /reports check with a path comparison (prevUrl !== location.pathname). This clears session storage whenever the user navigates to the report from any different page (dashboard, another report, or external link), while preserving state during same-page interactions like switching tabs or resizing.

Reproduction (from issue)

  1. Create custom report "test" (bar graph default)
  2. Go back to reports dashboard
  3. Open "test"
  4. Change graph to donut (don't save)
  5. Navigate back
  6. Open "test" again -- previously showed donut, now correctly shows bar graph

Fixes #7332

This contribution was developed with AI assistance (Claude Code).


Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 28 12.18 MB → 12.18 MB (+2.95 kB) +0.02%
loot-core 1 4.83 MB 0%
api 4 4.06 MB 0%
cli 1 7.88 MB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
28 12.18 MB → 12.18 MB (+2.95 kB) +0.02%
Changeset
File Δ Size
locale/zh-Hans.json 📈 +2.5 kB (+2.75%) 91.07 kB → 93.57 kB
locale/ca.json 📈 +456 B (+0.24%) 182.91 kB → 183.36 kB
src/components/reports/reports/CustomReport.tsx 📉 -1 B (-0.00%) 41.28 kB → 41.28 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/zh-Hans.js 91.07 kB → 93.57 kB (+2.5 kB) +2.75%
static/js/ca.js 182.91 kB → 183.36 kB (+456 B) +0.24%

Smaller

Asset File Size % Changed
static/js/ReportRouter.js 1.02 MB → 1.02 MB (-1 B) -0.00%

Unchanged

Asset File Size % Changed
static/js/index.js 3.23 MB 0%
static/js/BackgroundImage.js 119.98 kB 0%
static/js/FormulaEditor.js 846.44 kB 0%
static/js/TransactionList.js 81.29 kB 0%
static/js/da.js 104.66 kB 0%
static/js/de.js 174.79 kB 0%
static/js/en-GB.js 7.16 kB 0%
static/js/en.js 170.76 kB 0%
static/js/es.js 182.18 kB 0%
static/js/fr.js 177.47 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.46 kB 0%
static/js/it.js 166.25 kB 0%
static/js/narrow.js 354.5 kB 0%
static/js/nb-NO.js 152.2 kB 0%
static/js/nl.js 108.93 kB 0%
static/js/pl.js 88.34 kB 0%
static/js/pt-BR.js 177.84 kB 0%
static/js/resize-observer.js 18.03 kB 0%
static/js/sv.js 80.58 kB 0%
static/js/th.js 179.94 kB 0%
static/js/theme.js 30.68 kB 0%
static/js/uk.js 213.14 kB 0%
static/js/useTransactionBatchActions.js 4.29 MB 0%
static/js/wide.js 418 B 0%
static/js/workbox-window.prod.es5.js 7.28 kB 0%

loot-core

Total

Files count Total bundle size % Changed
1 4.83 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.B--GR9z4.js 4.83 MB 0%

api

Total

Files count Total bundle size % Changed
4 4.06 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
index.js 3.84 MB 0%
from-Bl-Hslp4.js 167.73 kB 0%
multipart-parser-BnDysoMr.js 8.1 kB 0%
src-iMkUmuwR.js 43.64 kB 0%

cli

Total

Files count Total bundle size % Changed
1 7.88 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
cli.js 7.88 MB 0%

The session storage clear condition only fired when navigating from
the /reports dashboard. Since the URL tracking runs inside the report
component, the stored URL always pointed to the last report path, so
revisiting the same report never triggered the clear.

Changed the condition to clear session storage whenever the stored URL
differs from the current path. This handles navigating from the
dashboard, from another report, or any other page.

Fixes actualbudget#7332
@actual-github-bot actual-github-bot bot changed the title Fix custom report editor retaining unsaved settings [WIP] Fix custom report editor retaining unsaved settings Apr 2, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit c90f0ed
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/69d0bce29e787a0008b48dff
😎 Deploy Preview https://deploy-preview-7356.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

👋 Hello contributor!

We would love to review your PR! Before we can do that, please make sure:

  • ✅ All CI checks pass
  • ✅ The PR is moved from draft to open (if applicable)
  • ✅ The "[WIP]" prefix is removed from the PR title
  • ✅ All CodeRabbit code review comments are resolved (if you disagree with anything - reply to the bot with your reasoning so we can read through it). The bot will eventually approve the PR.

We do this to reduce the TOIL the core contributor team has to go through for each PR and to allow for speedy reviews and merges.

For more information, please see our Contributing Guide.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

Session storage clearing in CustomReportInner was changed to run only when the previous URL differs from the current pathname (prevUrl !== location.pathname), so session-scoped unsaved report settings are cleared upon route changes rather than only when prevUrl === '/reports'.

Changes

Cohort / File(s) Summary
Session Storage State Reset
packages/desktop-client/src/components/reports/reports/CustomReport.tsx
Adjusted the condition that clears sessionStorage from checking prevUrl === '/reports' to prevUrl !== location.pathname, so temporary report state is reset when navigating between routes.
Release Notes
upcoming-release-notes/7356.md
Added a release notes entry documenting the bugfix for retaining unsaved custom report settings when navigating between reports.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

size small

Poem

🐰 I hopped through routes, a tinkering chap,
Unsaved tweaks once lingered on my lap.
A tiny path check, a clear little sweep,
Now old edits vanish when routes take a leap! ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly and concisely describes the main fix: custom report editor retaining unsaved settings, which matches the primary change in the changeset.
Linked Issues check ✅ Passed The pull request fully addresses issue #7332 by implementing the required fix: clearing session storage when navigating between reports so unsaved edits don't persist.
Out of Scope Changes check ✅ Passed All changes are in-scope: one-line fix to CustomReport.tsx logic and a corresponding release notes entry document the fix; no extraneous modifications present.
Description check ✅ Passed The pull request description is well-related to the changeset, clearly explaining the bug fix, root cause, and the one-line change made to CustomReport.tsx.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/desktop-client/src/components/reports/reports/CustomReport.tsx (1)

186-186: Consider adding a brief comment explaining the clearing condition.

The condition prevUrl !== location.pathname encodes domain logic ("clear unsaved state when navigating from a different route") that may not be immediately obvious to future maintainers.

📝 Suggested comment
+  // Clear session storage when navigating from a different route to reset unsaved changes
   if (prevUrl !== location.pathname) sessionStorage.clear();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/desktop-client/src/components/reports/reports/CustomReport.tsx` at
line 186, The line clearing sessionStorage when prevUrl !== location.pathname
encodes domain logic that isn't obvious; add a brief inline comment above the
check in CustomReport.tsx explaining that this condition clears unsaved report
state when the user navigates to a different route (i.e., when prevUrl differs
from location.pathname), and mention any assumptions (e.g., prevUrl holds the
last route for this report) so future maintainers understand why
sessionStorage.clear() is invoked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/desktop-client/src/components/reports/reports/CustomReport.tsx`:
- Line 186: The line clearing sessionStorage when prevUrl !== location.pathname
encodes domain logic that isn't obvious; add a brief inline comment above the
check in CustomReport.tsx explaining that this condition clears unsaved report
state when the user navigates to a different route (i.e., when prevUrl differs
from location.pathname), and mention any assumptions (e.g., prevUrl holds the
last route for this report) so future maintainers understand why
sessionStorage.clear() is invoked.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 60400474-5d38-461f-b9a2-f07920940c10

📥 Commits

Reviewing files that changed from the base of the PR and between 556bea0 and 594ccc0.

📒 Files selected for processing (1)
  • packages/desktop-client/src/components/reports/reports/CustomReport.tsx

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

🤖 Auto-generated Release Notes

Hey @tmchow! I've automatically created a release notes file based on CodeRabbit's analysis:

Category: Bugfixes
Summary: Fix unsaved settings retention in custom report editor during route navigation changes.
File: upcoming-release-notes/7356.md

If you're happy with this release note, you can add it to your pull request. If not, you'll need to add your own before a maintainer can review your change.

@tmchow tmchow changed the title [WIP] Fix custom report editor retaining unsaved settings Fix custom report editor retaining unsaved settings Apr 4, 2026
@coderabbitai coderabbitai bot removed the size small label Apr 4, 2026
@matt-fidd matt-fidd force-pushed the master branch 2 times, most recently from 5c7c70d to d262f7d Compare April 5, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: The custom report editor is retaining unsaved settings between viewing custom reports

1 participant