JSON editor: fix switching files and returning to the page #13

Merged
clayschaad merged 1 commit from fix-json-editor-file-switch into main 2026-10-30 21:09:28 +00:00
Owner

Switching the file in the JSON editor broke the page.

Cause

Pages are interactive one by one, so NavigationManager.NavigateTo and menu links run an enhanced navigation: the page is rendered again on the server and merged into the DOM, including <head>.

Fixes

  • Switching files: navigated to ?file=…; the editor kept the old file, and with the large Transactions.json its DOM got mangled. Now the file is loaded in place and only the URL is replaced (wwwroot/js/url.js, history.replaceState)
  • Leaving the page: OnParametersSetAsync ran again on the disposing editor, threw ObjectDisposedException and terminated the circuit. The file parameter is now only read in OnInitializedAsync
  • Coming back without a full reload: Monaco's stylesheets had been removed from <head>, so the editor was unstyled. monaco.js now remembers them and puts them back
  • CLAUDE.md note on this

Trade-off: switching files no longer adds history entries (back goes to the previous page).

Testing

  • Reproduced and verified with Playwright/Chrome against a second app instance (real data, no saves): switching through all files incl. Transactions.json, leaving and returning via menu and browser back, reload keeps the file; editor stays styled, no server errors
  • dotnet test 160 passed

🤖 Generated with Claude Code

Switching the file in the JSON editor broke the page. ## Cause Pages are interactive one by one, so `NavigationManager.NavigateTo` and menu links run an **enhanced navigation**: the page is rendered again on the server and merged into the DOM, including `<head>`. ## Fixes - **Switching files**: navigated to `?file=…`; the editor kept the old file, and with the large `Transactions.json` its DOM got mangled. Now the file is loaded in place and only the URL is replaced (`wwwroot/js/url.js`, `history.replaceState`) - **Leaving the page**: `OnParametersSetAsync` ran again on the disposing editor, threw `ObjectDisposedException` and terminated the circuit. The file parameter is now only read in `OnInitializedAsync` - **Coming back without a full reload**: Monaco's stylesheets had been removed from `<head>`, so the editor was unstyled. `monaco.js` now remembers them and puts them back - CLAUDE.md note on this Trade-off: switching files no longer adds history entries (back goes to the previous page). ## Testing - Reproduced and verified with Playwright/Chrome against a second app instance (real data, no saves): switching through all files incl. `Transactions.json`, leaving and returning via menu and browser back, reload keeps the file; editor stays styled, no server errors - `dotnet test` 160 passed 🤖 Generated with [Claude Code](https://claude.com/claude-code)
clayschaad added 1 commit 2026-10-30 21:09:27 +00:00
Pages are interactive one by one, so NavigateTo and menu links run an
enhanced navigation that re-renders the page on the server and syncs
<head>. That broke the editor in three ways:

- Switching files navigated to ?file=...: the editor kept the old file,
  and with the large Transactions.json its DOM got mangled. The file is
  now loaded in place and only the URL is replaced (js/url.js).
- Leaving the page re-ran OnParametersSetAsync on the disposing editor,
  which threw and terminated the circuit. The file parameter is now only
  read in OnInitializedAsync.
- Coming back without a full reload showed Monaco unstyled, because its
  stylesheets had been removed from <head>. monaco.js now remembers them
  and puts them back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clayschaad merged commit 651586c4f9 into main 2026-10-30 21:09:28 +00:00
clayschaad deleted branch fix-json-editor-file-switch 2026-10-30 21:09:28 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: clayschaad/AccountingNext#13
No description provided.