Sync Blazor templates with aspnetcore net11-pre4#35265
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35265Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35265" |
8a99d66 to
72b817b
Compare
Apply upstream changes from dotnet/aspnetcore BlazorWeb-CSharp template (release/10.0 → main/net11-pre4) to both maui-blazor and maui-blazor-solution templates: - ReconnectModal.razor: Resume button ordering + resume-failed class - ReconnectModal.razor.js: Show resume-failed state instead of reload - ReconnectModal.razor.css: Fix &[open] CSS nesting indentation - Web.Client Program.cs/Main.cs: Use AddAuthenticationStateDeserialization() - template.json: Add onlyIf localhost constraint on port replacers - template.json: Add *.razor.js to copyOnly for co-located JS files - index.html: Add SampleContent-guarded NavMenu.razor.js script refs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
72b817b to
ce11f67
Compare
|
|
|
/review -b feature/refactor-copilot-yml |
|
|
AI code review for net11.0 targetVerdict: LGTM Template-only sync of the Blazor ( Key findings
CI note: Most legs green. The Confidence: High. This is an automated, non-approval review comment, not a GitHub approval/request-changes. A human must make the merge decision. |
kubaflo
left a comment
There was a problem hiding this comment.
Cross-model synthesis — dotnet/maui PR #35265 (Sync Blazor templates with aspnetcore net11-pre4)
Verdict: NEEDS_CHANGES (confidence: medium)
gpt-5.5's lone finding is CONFIRMED real, not a false positive. The added index.html module reference (maui-blazor/wwwroot/index.html:30 and maui-blazor-solution/MauiApp.1/wwwroot/index.html:25) is a deferred type="module" script that evaluates during the initial WebView page load; because MAUI Hybrid has no prerendering and uses autostart="false", the NavMenu has not been rendered into #app yet, so NavMenu.razor.js's one-shot getElementById("nav-scrollable") returns null, the if guard short-circuits (no null-ref, but no listener attaches), and it never re-runs — the mobile nav auto-collapse that net10's inline onclick provided is not restored in generated Hybrid apps. This is not mitigated by defer/DOMContentLoaded/event-delegation and does NOT match the upstream mechanism (which works only via SSR prerendering, absent in Hybrid); the pattern exists in no shipping branch (net10.0, net11.0 base, release/10.0.1xx, main). The other 8 changed lines (copyOnly **/*.razor.js, onlyIf localhost port guard, AddAuthenticationStateDeserialization(), ReconnectModal razor/css/js) are verified correct as the 3 other models found.
CI: maui-pr is RED — Build Analysis + RunOniOS_*Release/TrimFull(_CoreCLR) + AOT macOS legs fail; these exercise the plain MAUI template (not these Blazor files) and read as shared infra/flaky (Blazor/Build/Samples/MultiProject/WindowsTemplates legs pass). Verdict is driven by the confirmed finding, not CI.
|
|
||
| <script src="_framework/blazor.webview.js" autostart="false"></script> | ||
| <!--#if (SampleContent) --> | ||
| <script type="module" src="Components/Layout/NavMenu.razor.js"></script> |
There was a problem hiding this comment.
This added <script type="module" src="Components/Layout/NavMenu.razor.js"> is a deferred module that evaluates during the initial WebView page load. In MAUI Blazor Hybrid there is no prerendering and blazor.webview.js is loaded with autostart="false", so when this module runs #app is still Loading... and the NavMenu has not been rendered yet. NavMenu.razor.js does a one-shot document.getElementById("nav-scrollable") / document.querySelector(".navbar-toggler"); both return null, the if (navScrollable && navToggler) guard short-circuits (so no null-ref, but no listener is attached), and the module never re-runs after Blazor renders. Net effect: the click-to-collapse behavior that net10's inline onclick provided is NOT restored in generated Hybrid apps. The co-located <script> inside NavMenu.razor does not help either, since Blazor-inserted <script> elements don't execute. The same applies to src/Templates/src/templates/maui-blazor-solution/MauiApp.1/wwwroot/index.html:25. Upstream works only because of SSR prerendering, which Hybrid lacks. Fix by attaching after Blazor has started (e.g. Blazor.start().then(...) / afterStarted) or by using event delegation on a stable ancestor / re-querying after render.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description
Syncs both MAUI Blazor templates (
maui-blazorandmaui-blazor-web) with upstream changes fromdotnet/aspnetcoreBlazorWeb-CSharp template (release/10.0→main/net11-pre4).Changes
Both templates
onclickhandler withid="nav-scrollable"+ JS module (CSP compliance)**/*.razor.jstocopyOnlyso template engine emits co-located JS filesmaui-blazor(standalone)<script>reference for NavMenu.razor.jsmaui-blazor-solution(multi-project)<base href="/" />→<BasePath />component&[open]CSS nesting indentation[PersistentState]on RequestId,public,??=assignment@using Microsoft.AspNetCore.Components.EndpointsonlyIflocalhost constraint on port replacersPersistentAuthenticationStateProvider→AddAuthenticationStateDeserialization()Not synced (intentional)