Skip to content

Fix #17: per-sample description missing on first nav + scrollbar/schema fixes#20

Closed
TimPurdum wants to merge 1 commit into
feature/schema-org-jsonldfrom
claude/review-pr-17-fixes-0VKL3
Closed

Fix #17: per-sample description missing on first nav + scrollbar/schema fixes#20
TimPurdum wants to merge 1 commit into
feature/schema-org-jsonldfrom
claude/review-pr-17-fixes-0VKL3

Conversation

@TimPurdum
Copy link
Copy Markdown
Contributor

Follow-up fixes for #17 addressing Tim's testing feedback and the two unresolved Copilot review comments.

Tim's feedback

"About this page" never shows on first navigation from the navbar, only after a page refresh.
The Schema.org LD-JSON is too static for the site, each page should have somewhat different content, especially the description and url.

Root cause for both: the MainLayout.OnLocationChanged handler cleared LayoutService.CurrentPage on every navigation, expecting the next SamplePage.OnInitialized to re-register. But on first nav from the navbar, the layout's render after the clear could land before the new SamplePage had run its OnInitialized, so the description / SoftwareSourceCode / per-page meta tags rendered against CurrentPage == null. That's also why the JSON-LD looked "static" — the per-page description / SoftwareSourceCode entry was missing on first paint.

Fix: key LayoutService.CurrentPage to the URI it was registered for. SamplePage.OnInitialized now passes NavigationManager.Uri when calling SetCurrentPage. MainLayout reads through a new EffectiveCurrentPage getter that only returns the registered page when its URI matches NavigationManager.Uri. No timing dependency, and stale references after navigating to a non-SamplePage route (Home/NotFound) are silently ignored — same guarantee the explicit ClearCurrentPage was trying to provide, without the race.

While there, enrich the per-page JSON-LD with keywords derived from the page name plus mainEntity / mainEntityOfPage cross-references between WebPage and SoftwareSourceCode, so each sample page emits visibly distinct schema content beyond just url/name.

Unresolved Copilot comments addressed

  • Nested scrolling on narrow layouts (MainLayout.razor.css:63): article.content had a fixed height: calc(100vh - 10rem) + overflow-y: auto at all widths, and on <1075px so did the parent <main> — double scrollbars. Moved both into the >=1075px media query, where <main> switches to overflow:hidden and inner article scrolling is what we want.
  • Stale CurrentPage after navigating to a non-SamplePage route: subsumed by the URI-key approach above (the thread was marked resolved by the original ClearCurrentPage change, but the new approach handles both this case and Tim's first-nav case with a single mechanism).

Other Copilot comments were already addressed in the existing PR commits (Dispose() no longer disposes the injected HttpClient; summary::marker cleared for cross-browser parity; MetaTitle only appends "— GeoBlazor Sample" when on a sample page; SlugToTitle takes the last /-segment; CanonicalPageUrl strips query/fragment).

Files changed

  • LayoutService.cs — add PageUri; SetCurrentPage(page, uri); drop ClearCurrentPage (no longer needed)
  • SamplePage.cs — inject NavigationManager; pass Uri when registering
  • MainLayout.razorEffectiveCurrentPage getter; use it in render, meta tags, and JSON-LD; OnLocationChanged now just calls StateHasChanged; enrich JSON-LD per-page
  • MainLayout.razor.css — move article fixed-height + overflow into >=1075px media query

Test plan

  • On first-time navigation from navbar (cold load to Home, then click a sample link), "About this sample" details block renders without refresh.
  • Per-page <meta name="description">, og:url, and JSON-LD WebPage/SoftwareSourceCode reflect the new sample on each navigation.
  • Navigate from a sample to Home — description disappears, no stale per-page meta.
  • On <1075px viewport, no nested/double scrollbars on sample pages with long content.
  • On >=1075px, article still scrolls independently inside main as before.

Targets feature/schema-org-jsonld so it stacks into #17.


Generated by Claude Code

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 <main> is set to
overflow:hidden).
@TimPurdum TimPurdum closed this May 19, 2026
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.

2 participants