Skip to content

docs(hydrogen): mark the current page in the sample nav - #760

Draft
romain-pm wants to merge 1 commit into
feat/link-apifrom
feat/hydrogen-navbar-jlink
Draft

docs(hydrogen): mark the current page in the sample nav#760
romain-pm wants to merge 1 commit into
feat/link-apifrom
feat/hydrogen-navbar-jlink

Conversation

@romain-pm

Copy link
Copy Markdown

Summary

Makes the current page actually show as current in the hydrogen navigation. Stacked on #751; the diff here is nine lines in one sample file.

Why

The nav marked the current entry with aria-current={page === mainNode ? "page" : undefined}. Both sides are Graal host proxies wrapping a JCR node, and two proxies for the same node are not the same object — so the test never passed and aria-current never appeared. <JLink> compares identifiers instead.

Changes

  • Both link sites become <JLink node={page} />. No children, so the label comes from the page's displayable name.
  • The view declares properties: { "cache.mainResource": "true" }. Current-page state 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 without this the nav would be cached once and replayed on every page with the same entry marked current. Nothing in this monorepo declared the property before; core declares it on jnt_navMenu, jnt_area and the other main-resource-dependent views, and Jahia/luxe-jahia-demo declares it on its own nav.

Validation

Why it is separate from #751

#751 adopts the API mechanically. This changes what the reference sample renders — aria-current appears where it never did, on the navigation every new module copies — and it introduces a caching rule the docs have never stated. Worth its own review rather than one line in a 12-file diff.

Part of #759. Depends on #751.

@pkg-pr-new

pkg-pr-new Bot commented Aug 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

yarn add https://pkg.pr.new/@jahia/create-module@760.tgz
yarn add https://pkg.pr.new/@jahia/javascript-modules-library@760.tgz
yarn add https://pkg.pr.new/@jahia/vite-plugin@760.tgz

commit: 1a43a3f

The nav decided the current page with `page === mainNode`, reference
equality on two Graal host proxies, which are never the same object —
so aria-current never appeared. JLink compares identifiers.

Marking the current page makes the fragment depend on the main
resource, which is not part of the cache key unless the view says so,
hence cache.mainResource.

Refs #759
@romain-pm
romain-pm force-pushed the feat/hydrogen-navbar-jlink branch from 281b2cc to 1a43a3f Compare August 23, 2026 22:21
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.

1 participant