Skip to content

hydrogen NavBar: current-page state that actually works, and is cached correctly #759

Description

@romain-pm

Part of #749. Split out of #751 because it changes what the reference sample renders, rather than adopting an API mechanically.

samples/hydrogen's NavBar decides the current page with page === mainNode — reference equality on two Graal host proxies, which are not the same object. So aria-current never appears on the canonical navigation sample today. <JLink node={page} /> compares identifiers, and it starts appearing.

That is a fix, but it is newly visible output on the sample everyone copies, and it comes with a caching obligation the monorepo has never mentioned.

  • Move both link sites to <JLink node={page} />, label derived from the page.
  • Declare properties: { "cache.mainResource": "true" }. aria-current is a function of the main resource, and PathCacheKeyPartGenerator leaves the main resource out of the fragment cache key unless the view opts in — so a nav shared across pages is cached once and replayed with the wrong entry marked current. See cache.mainResource: make current-page state safe to cache #755.
  • Confirm on a running instance that the nav is not over-cached: render it on two pages and assert aria-current follows.
  • Decide whether the getting-started nav chapter needs the same treatment.

Depends on #751 (the <JLink> implementation).

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions