From 9e65df77025c9b4091a7662d0533c0a15d0fd461 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 19 May 2026 21:59:35 +0000 Subject: [PATCH] Key sample-page metadata to URI to fix first-nav rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "About this sample" details block, per-page meta tags, and JSON-LD SoftwareSourceCode entry were missing on the first navigation from the navbar — they only appeared after a page refresh. The cause was a render-order race in MainLayout: the LocationChanged handler cleared LayoutService.CurrentPage, but on first navigation the layout could re-render with the new URL before the new SamplePage's OnInitialized had a chance to re-register itself. Replace the clear-on-navigation approach with a URI key on LayoutService — SamplePage records the URI it set CurrentPage for, and MainLayout's new EffectiveCurrentPage getter only treats CurrentPage as live when that URI matches NavigationManager.Uri. Stale references after navigating to a non-SamplePage route are silently ignored with no timing dependency. While there, enrich the per-page JSON-LD with keywords and mainEntity/mainEntityOfPage cross-references so each sample page emits visibly distinct schema.org content, and fix the unresolved double scrollbar on narrow screens by moving article.content's fixed height and overflow-y into the >=1075px media query (where
is set to overflow:hidden). --- .../Shared/LayoutService.cs | 19 ++-- .../Shared/MainLayout.razor | 99 +++++++++++++------ .../Shared/MainLayout.razor.css | 8 +- .../Shared/SamplePage.cs | 5 +- 4 files changed, 88 insertions(+), 43 deletions(-) diff --git a/samples/core/dymaptic.GeoBlazor.Core.Sample.Shared/Shared/LayoutService.cs b/samples/core/dymaptic.GeoBlazor.Core.Sample.Shared/Shared/LayoutService.cs index 9bf823e..371c883 100644 --- a/samples/core/dymaptic.GeoBlazor.Core.Sample.Shared/Shared/LayoutService.cs +++ b/samples/core/dymaptic.GeoBlazor.Core.Sample.Shared/Shared/LayoutService.cs @@ -1,21 +1,22 @@ namespace dymaptic.GeoBlazor.Core.Sample.Shared.Shared; -// LayoutStateService.cs public class LayoutService { public SamplePage? CurrentPage { get; private set; } + + // URI the CurrentPage was registered for. Consumers should only treat + // CurrentPage as live when this matches the layout's current URI — + // that way stale references from a previously-rendered SamplePage are + // silently ignored after navigation, with no race against component + // initialization order. + public string? PageUri { get; private set; } + public event Action? OnPageChanged; - public void SetCurrentPage(SamplePage page) + public void SetCurrentPage(SamplePage page, string uri) { CurrentPage = page; - OnPageChanged?.Invoke(); - } - - public void ClearCurrentPage() - { - if (CurrentPage is null) return; - CurrentPage = null; + PageUri = uri; OnPageChanged?.Invoke(); } } \ No newline at end of file diff --git a/samples/core/dymaptic.GeoBlazor.Core.Sample.Shared/Shared/MainLayout.razor b/samples/core/dymaptic.GeoBlazor.Core.Sample.Shared/Shared/MainLayout.razor index 5fe5762..c6558b3 100644 --- a/samples/core/dymaptic.GeoBlazor.Core.Sample.Shared/Shared/MainLayout.razor +++ b/samples/core/dymaptic.GeoBlazor.Core.Sample.Shared/Shared/MainLayout.razor @@ -23,13 +23,13 @@