From c07fd2893e07de2c5155ee8de012c013d282baf2 Mon Sep 17 00:00:00 2001 From: Claudio Schaad Date: Fri, 30 Oct 2026 22:21:08 +0100 Subject: [PATCH] Fix menu link click error and charts failing after the JSON editor - NavMenu: drop CustomToggle="true" (left over from the project template). It made every nav link run document.getElementById('navmenu-toggle').click(), but there is no such element, so each click threw a TypeError. - charts.js: Monaco's AMD loader (JSON editor) leaves a global define() and pages switch without a full reload. Chart.js and the treemap plugin are UMD bundles that then register as AMD modules instead of setting window.Chart, so Analyse, Strom and Wasser failed with "Cannot read properties of undefined (reading 'defaults')" and the circuit was terminated. define is now hidden while they load, through one shared loading promise so concurrent charts can't restore it wrongly. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 2 +- .../Components/Layout/NavMenu.razor | 2 +- Schaad.Accounting.UI/wwwroot/js/charts.js | 49 ++++++++++++------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 19e00f5..98801b5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -77,7 +77,7 @@ Pages live in `Schaad.Accounting.UI/Components/Pages/`. Each page typically has - `Microsoft.FluentUI.AspNetCore.Components` — UI components (FluentDataGrid, FluentDialog, etc.) - `Plotly.Blazor` — charts on the older chart pages - `BlazorMonaco` — Monaco editor for the JSON editor page; loaded on demand by `wwwroot/js/monaco.js` instead of script tags in `App.razor`. Pages are interactive one by one, so `NavigationManager.NavigateTo` and menu links run enhanced navigation, which syncs `` (removing Monaco's styles; `monaco.js` puts them back) and re-renders the page on the server. The editor therefore switches files in place and only rewrites the URL (`wwwroot/js/url.js`) -- Chart.js 4 + `chartjs-chart-treemap` — charts on the Analyse page; vendored in `wwwroot/lib/` (no CDN), wrapped by `wwwroot/js/charts.js` and `ChartJsChart.razor` +- Chart.js 4 + `chartjs-chart-treemap` — charts on the Analyse page; vendored in `wwwroot/lib/` (no CDN), wrapped by `wwwroot/js/charts.js` and `ChartJsChart.razor`; `charts.js` hides Monaco's global AMD `define` while loading them, otherwise the UMD bundles register as AMD modules and `window.Chart` stays undefined after visiting the JSON editor - `FreeSpire.PDF` — PDF parsing for bank statement imports - `Schaad.Finance.dll` / `Schaad.Finance.Api.dll` — proprietary DLLs for MT940/CAMT053 parsing and FX rate lookups (FixerIo API key in `appsettings.Development.json`) diff --git a/Schaad.Accounting.UI/Components/Layout/NavMenu.razor b/Schaad.Accounting.UI/Components/Layout/NavMenu.razor index 8d099d5..ebfb65d 100644 --- a/Schaad.Accounting.UI/Components/Layout/NavMenu.razor +++ b/Schaad.Accounting.UI/Components/Layout/NavMenu.razor @@ -5,7 +5,7 @@