JSON editor: fix switching files and returning to the page #13
Loading…
Reference in a new issue
No description provided.
Delete branch "fix-json-editor-file-switch"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Switching the file in the JSON editor broke the page.
Cause
Pages are interactive one by one, so
NavigationManager.NavigateToand menu links run an enhanced navigation: the page is rendered again on the server and merged into the DOM, including<head>.Fixes
?file=…; the editor kept the old file, and with the largeTransactions.jsonits DOM got mangled. Now the file is loaded in place and only the URL is replaced (wwwroot/js/url.js,history.replaceState)OnParametersSetAsyncran again on the disposing editor, threwObjectDisposedExceptionand terminated the circuit. The file parameter is now only read inOnInitializedAsync<head>, so the editor was unstyled.monaco.jsnow remembers them and puts them backTrade-off: switching files no longer adds history entries (back goes to the previous page).
Testing
Transactions.json, leaving and returning via menu and browser back, reload keeps the file; editor stays styled, no server errorsdotnet test160 passed🤖 Generated with Claude Code