From ce11f67da0d49f8844aed7c6a4bfad77d92281d9 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Thu, 7 May 2026 23:24:48 +0200 Subject: [PATCH 1/5] Sync Blazor templates with aspnetcore net11-pre4 changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- .../.template.config/template.json | 13 ++++++++++--- .../MauiApp.1.Web.Client/Program.Main.cs | 2 +- .../MauiApp.1.Web.Client/Program.cs | 2 +- .../Components/Layout/ReconnectModal.razor | 8 ++++---- .../Components/Layout/ReconnectModal.razor.css | 11 ++++------- .../Components/Layout/ReconnectModal.razor.js | 2 +- .../MauiApp.1/wwwroot/index.html | 3 +++ .../maui-blazor/.template.config/template.json | 3 ++- .../src/templates/maui-blazor/wwwroot/index.html | 3 +++ 9 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/Templates/src/templates/maui-blazor-solution/.template.config/template.json b/src/Templates/src/templates/maui-blazor-solution/.template.config/template.json index 0254c7879659..2e3cbeb02fae 100644 --- a/src/Templates/src/templates/maui-blazor-solution/.template.config/template.json +++ b/src/Templates/src/templates/maui-blazor-solution/.template.config/template.json @@ -65,7 +65,8 @@ "copyOnly": [ "**/wwwroot/lib/bootstrap/**", "**/*.svg", - "**/*.ttf" + "**/*.ttf", + "**/*.razor.js" ], "modifiers": [ { @@ -289,7 +290,10 @@ "sourceVariableName": "kestrelHttpPort", "fallbackVariableName": "kestrelHttpPortGenerated" }, - "replaces": "5500" + "replaces": "5500", + "onlyIf": [{ + "after": "localhost:" + }] }, "kestrelHttpsPort": { "type": "parameter", @@ -311,7 +315,10 @@ "sourceVariableName": "kestrelHttpsPort", "fallbackVariableName": "kestrelHttpsPortGenerated" }, - "replaces": "5501" + "replaces": "5501", + "onlyIf": [{ + "after": "localhost:" + }] }, "iisHttpPort": { "type": "parameter", diff --git a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/Program.Main.cs b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/Program.Main.cs index b3f43b093aef..0e8b7522468f 100644 --- a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/Program.Main.cs +++ b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/Program.Main.cs @@ -20,7 +20,7 @@ static async Task Main(string[] args) #if (IndividualLocalAuth) builder.Services.AddAuthorizationCore(); builder.Services.AddCascadingAuthenticationState(); - builder.Services.AddSingleton(); + builder.Services.AddAuthenticationStateDeserialization(); #endif await builder.Build().RunAsync(); diff --git a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/Program.cs b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/Program.cs index 2f33fefcbf6a..03b60f96155e 100644 --- a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/Program.cs +++ b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/Program.cs @@ -14,7 +14,7 @@ #if (IndividualLocalAuth) builder.Services.AddAuthorizationCore(); builder.Services.AddCascadingAuthenticationState(); -builder.Services.AddSingleton(); +builder.Services.AddAuthenticationStateDeserialization(); #endif await builder.Build().RunAsync(); diff --git a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor index a85217a1132b..44f63561f43a 100644 --- a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor +++ b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor @@ -25,11 +25,11 @@

The session has been paused by the server.

-

- Failed to resume the session.
Please reload the page. + Failed to resume the session.
Please retry or reload the page.

+ diff --git a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor.css b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor.css index 3ad3773f39db..77e79175b2bb 100644 --- a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor.css +++ b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor.css @@ -31,13 +31,10 @@ opacity: 0; transition: display 0.5s allow-discrete, overlay 0.5s allow-discrete; animation: components-reconnect-modal-fadeOutOpacity 0.5s both; - &[open] - -{ - animation: components-reconnect-modal-slideUp 1.5s cubic-bezier(.05, .89, .25, 1.02) 0.3s, components-reconnect-modal-fadeInOpacity 0.5s ease-in-out 0.3s; - animation-fill-mode: both; -} - + &[open] { + animation: components-reconnect-modal-slideUp 1.5s cubic-bezier(.05, .89, .25, 1.02) 0.3s, components-reconnect-modal-fadeInOpacity 0.5s ease-in-out 0.3s; + animation-fill-mode: both; + } } #components-reconnect-modal::backdrop { diff --git a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor.js b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor.js index e52a190bacbb..a44de78d836d 100644 --- a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor.js +++ b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Components/Layout/ReconnectModal.razor.js @@ -52,7 +52,7 @@ async function resume() { location.reload(); } } catch { - location.reload(); + reconnectModal.classList.replace("components-reconnect-paused", "components-reconnect-resume-failed"); } } diff --git a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1/wwwroot/index.html b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1/wwwroot/index.html index 95bdeebf0c9a..1eb215e98574 100644 --- a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1/wwwroot/index.html +++ b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1/wwwroot/index.html @@ -21,6 +21,9 @@
Loading...
+ + + diff --git a/src/Templates/src/templates/maui-blazor/.template.config/template.json b/src/Templates/src/templates/maui-blazor/.template.config/template.json index 94d323cf9e67..f92039123c61 100644 --- a/src/Templates/src/templates/maui-blazor/.template.config/template.json +++ b/src/Templates/src/templates/maui-blazor/.template.config/template.json @@ -52,7 +52,8 @@ "copyOnly": [ "**/wwwroot/lib/bootstrap/**", "**/*.svg", - "**/*.ttf" + "**/*.ttf", + "**/*.razor.js" ], "modifiers": [ { diff --git a/src/Templates/src/templates/maui-blazor/wwwroot/index.html b/src/Templates/src/templates/maui-blazor/wwwroot/index.html index 5eca68ef87e5..f01df694713a 100644 --- a/src/Templates/src/templates/maui-blazor/wwwroot/index.html +++ b/src/Templates/src/templates/maui-blazor/wwwroot/index.html @@ -26,6 +26,9 @@ + + + From cf0a5aa7c40dcd79fcaaa35c6e6aa8bd4aaf9fa0 Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Tue, 14 Jul 2026 05:10:59 +0200 Subject: [PATCH 2/5] Fix MAUI Blazor Hybrid NavMenu collapse (#35265) Use document-level event delegation so the generated Hybrid templates attach the collapse behavior even when the module loads before Blazor renders the NavMenu. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../MauiApp.1.Shared/Layout/NavMenu.razor.js | 13 ++++++++----- .../maui-blazor/Components/Layout/NavMenu.razor.js | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor.js b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor.js index 2ad21bdb4852..78bf102651d4 100644 --- a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor.js +++ b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor.js @@ -1,9 +1,12 @@ // Handle navigation menu toggle -const navScrollable = document.getElementById("nav-scrollable"); -const navToggler = document.querySelector(".navbar-toggler"); +if (!globalThis.__mauiNavMenuCollapseInitialized) { + globalThis.__mauiNavMenuCollapseInitialized = true; -if (navScrollable && navToggler) { - navScrollable.addEventListener("click", function() { - navToggler.click(); + document.addEventListener("click", function(event) { + const target = event.target; + + if (target instanceof Element && target.closest("#nav-scrollable")) { + document.querySelector(".navbar-toggler")?.click(); + } }); } diff --git a/src/Templates/src/templates/maui-blazor/Components/Layout/NavMenu.razor.js b/src/Templates/src/templates/maui-blazor/Components/Layout/NavMenu.razor.js index 2ad21bdb4852..78bf102651d4 100644 --- a/src/Templates/src/templates/maui-blazor/Components/Layout/NavMenu.razor.js +++ b/src/Templates/src/templates/maui-blazor/Components/Layout/NavMenu.razor.js @@ -1,9 +1,12 @@ // Handle navigation menu toggle -const navScrollable = document.getElementById("nav-scrollable"); -const navToggler = document.querySelector(".navbar-toggler"); +if (!globalThis.__mauiNavMenuCollapseInitialized) { + globalThis.__mauiNavMenuCollapseInitialized = true; -if (navScrollable && navToggler) { - navScrollable.addEventListener("click", function() { - navToggler.click(); + document.addEventListener("click", function(event) { + const target = event.target; + + if (target instanceof Element && target.closest("#nav-scrollable")) { + document.querySelector(".navbar-toggler")?.click(); + } }); } From 85554a9dc6f3981e8abcc2561a4f3211fdc0d05a Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Tue, 14 Jul 2026 06:38:36 +0200 Subject: [PATCH 3/5] Align Blazor WebAssembly auth package version (#35265) Use the existing WebAssembly package version token for the auth package so generated auth-enabled Web.Client projects can call AddAuthenticationStateDeserialization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../MauiApp.1.Web.Client/MauiApp.1.Web.Client.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/MauiApp.1.Web.Client.csproj b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/MauiApp.1.Web.Client.csproj index 1bc7b21155cb..6a445b0ea71e 100644 --- a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/MauiApp.1.Web.Client.csproj +++ b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web.Client/MauiApp.1.Web.Client.csproj @@ -10,7 +10,7 @@ - + From 6a393d20521adda9759b96e66f4efd230196266d Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Tue, 14 Jul 2026 07:36:29 +0200 Subject: [PATCH 4/5] Avoid opening NavMenu from delegated collapse handler (#35265) Only forward delegated nav clicks to the hidden checkbox when the mobile menu is already open, so desktop nav clicks do not leave the menu pre-opened after a later resize. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../MauiApp.1.Shared/Layout/NavMenu.razor.js | 6 +++++- .../maui-blazor/Components/Layout/NavMenu.razor.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor.js b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor.js index 78bf102651d4..174266044f43 100644 --- a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor.js +++ b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor.js @@ -6,7 +6,11 @@ if (!globalThis.__mauiNavMenuCollapseInitialized) { const target = event.target; if (target instanceof Element && target.closest("#nav-scrollable")) { - document.querySelector(".navbar-toggler")?.click(); + const navToggler = document.querySelector(".navbar-toggler"); + + if (navToggler instanceof HTMLInputElement && navToggler.checked) { + navToggler.click(); + } } }); } diff --git a/src/Templates/src/templates/maui-blazor/Components/Layout/NavMenu.razor.js b/src/Templates/src/templates/maui-blazor/Components/Layout/NavMenu.razor.js index 78bf102651d4..174266044f43 100644 --- a/src/Templates/src/templates/maui-blazor/Components/Layout/NavMenu.razor.js +++ b/src/Templates/src/templates/maui-blazor/Components/Layout/NavMenu.razor.js @@ -6,7 +6,11 @@ if (!globalThis.__mauiNavMenuCollapseInitialized) { const target = event.target; if (target instanceof Element && target.closest("#nav-scrollable")) { - document.querySelector(".navbar-toggler")?.click(); + const navToggler = document.querySelector(".navbar-toggler"); + + if (navToggler instanceof HTMLInputElement && navToggler.checked) { + navToggler.click(); + } } }); } From 6daac0cc27fdd9c73d9ec73f4bdcac30372000eb Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Tue, 14 Jul 2026 20:47:36 +0200 Subject: [PATCH 5/5] Clarify intentional dual NavMenu.razor.js load for #35265 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor | 1 + .../maui-blazor-solution/MauiApp.1/wwwroot/index.html | 1 + .../src/templates/maui-blazor/Components/Layout/NavMenu.razor | 3 ++- src/Templates/src/templates/maui-blazor/wwwroot/index.html | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor index 0f946f9fccef..278de4ae610c 100644 --- a/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor +++ b/src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Shared/Layout/NavMenu.razor @@ -4,6 +4,7 @@ @inject NavigationManager NavigationManager ##endif*@ +@* NavMenu.razor.js is also loaded early from index.html so the document-level delegated collapse handler is ready before Hybrid renders this menu (no SSR prerender). The module is idempotent via globalThis.__mauiNavMenuCollapseInitialized, so listeners register once. *@