Skip to content

Sync Blazor templates with aspnetcore net11-pre4#35265

Open
mattleibow wants to merge 1 commit into
net11.0from
mattleibow/blazor-template-sync-net11-pre4
Open

Sync Blazor templates with aspnetcore net11-pre4#35265
mattleibow wants to merge 1 commit into
net11.0from
mattleibow/blazor-template-sync-net11-pre4

Conversation

@mattleibow

Copy link
Copy Markdown
Member

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-blazor and maui-blazor-web) with upstream changes from dotnet/aspnetcore BlazorWeb-CSharp template (release/10.0main/net11-pre4).

Changes

Both templates

  • NavMenu.razor: Replace inline onclick handler with id="nav-scrollable" + JS module (CSP compliance)
  • NEW NavMenu.razor.js: Co-located JS click handler for nav toggle
  • template.json: Add **/*.razor.js to copyOnly so template engine emits co-located JS files

maui-blazor (standalone)

  • index.html: Add <script> reference for NavMenu.razor.js

maui-blazor-solution (multi-project)

  • App.razor: <base href="/" /><BasePath /> component
  • ReconnectModal.razor: Resume button ordering + resume-failed-visible class
  • ReconnectModal.razor.js: Resume failure shows state instead of force-reload
  • ReconnectModal.razor.css: Fix &[open] CSS nesting indentation
  • Error.razor: [PersistentState] on RequestId, public, ??= assignment
  • _Imports.razor (Web): Add @using Microsoft.AspNetCore.Components.Endpoints
  • template.json: Add onlyIf localhost constraint on port replacers
  • Web.Client Program.cs/Main.cs: PersistentAuthenticationStateProviderAddAuthenticationStateDeserialization()
  • index.html: Add NavMenu.razor.js script reference

Not synced (intentional)

  • Account/Identity pages (not in MAUI templates)
  • Data/migrations (not in MAUI templates)
  • Localize files (auto-generated)

Copilot AI review requested due to automatic review settings April 30, 2026 19:20
@github-actions

github-actions Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35265

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35265"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

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>
@mattleibow mattleibow force-pushed the mattleibow/blazor-template-sync-net11-pre4 branch from 72b817b to ce11f67 Compare May 7, 2026 21:25
@MauiBot

MauiBot commented May 8, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Merge Conflict Detected — This PR has merge conflicts with its target branch. Please rebase onto the target branch and resolve the conflicts.

@kubaflo

kubaflo commented May 24, 2026

Copy link
Copy Markdown
Contributor

/review -b feature/refactor-copilot-yml

@MauiBot

MauiBot commented May 24, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Merge Conflict Detected — This PR has merge conflicts with its target branch. Please rebase onto the target branch and resolve the conflicts.

@kubaflo

kubaflo commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

AI code review for net11.0 target

Verdict: LGTM

Template-only sync of the Blazor (maui-blazor, maui-blazor-solution) templates with aspnetcore net11-pre4.

Key findings

  • copyOnly now includes **/*.razor.js, and the new <script> references (Components/Layout/NavMenu.razor.js and _content/MauiApp.1.Shared/Layout/NavMenu.razor.js) resolve to files that do exist at the PR head — no dangling reference / 404.
  • kestrelHttpPort/kestrelHttpsPort now carry onlyIf: after "localhost:", correctly scoping port substitution to the localhost:5500/5501 occurrences instead of any literal 5500/5501.
  • Auth wiring swap to AddAuthenticationStateDeserialization() and the ReconnectModal markup/CSS/JS changes mirror the upstream aspnetcore templates; resume-failed UX is an improvement over forced reload.
  • No blocking code issues found.

CI note: Most legs green. The RunOniOS_*Release/TrimFull + AOT failures also appear on unrelated net11 PRs in this batch, so they read as shared infra/flaky failures rather than template-caused. Integration Blazor/Build/Samples legs (the ones that actually exercise these templates) pass.

Confidence: High.

This is an automated, non-approval review comment, not a GitHub approval/request-changes. A human must make the merge decision.

@kubaflo kubaflo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants