Skip to content

🐛 Fixed navigation markup changing for themes without the icons flag - #30129

Merged
acburdine merged 1 commit into
mainfrom
fix-navigation-tpl-flag-off
Aug 19, 2026
Merged

acburdine merged 1 commit into
mainfrom
fix-navigation-tpl-flag-off

Conversation

@acburdine

Copy link
Copy Markdown
Member

no ref

#28368 added icons and visibility controls to navigation behind the navigationIcons lab flag, but one part of it shipped ungated: the built-in navigation partial started wrapping every label in <span class="nav-label">.

That affects every theme that uses {{navigation}} without shipping its own partials/navigation.hbs, whether or not the flag is on. CSS and JS that target the anchor's text directly — .nav a flex/gap layouts, ::before tricks, truncation on the anchor, a.textContent reads — see different markup than before.

The helper now passes the flag to the template as @navigationIcons, and the template renders the icon plus the label wrapper only when it is set. With the flag off, output is byte-identical to the pre-#28368 markup.

The flag-off tests now assert the bare label, plus a new test that asserts the full rendered string matches the old markup exactly.

no ref

The navigation icons work wrapped every label in the built-in navigation
partial in `<span class="nav-label">`, but that wrapper was not gated on
the `navigationIcons` flag. Every theme that relies on the built-in
partial rather than shipping its own `partials/navigation.hbs` got new
markup inside the anchor, which can break CSS and JS that targets the
anchor's text directly.

The helper now passes the flag through to the template as
`@navigationIcons`, and the template only renders the icon and the label
wrapper when it is set. With the flag off the output is byte-identical
to the pre-flag markup, which the new test asserts in full.
@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Pro Plus

Run ID: 4be129ae-af1f-4a73-9233-7564c025f4e3

📥 Commits

Reviewing files that changed from the base of the PR and between cef5922 and df4b40c.

📒 Files selected for processing (3)
  • ghost/core/core/frontend/helpers/navigation.js
  • ghost/core/core/frontend/helpers/tpl/navigation.hbs
  • ghost/core/test/unit/frontend/helpers/navigation.test.js

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (14)
  • GitHub Check: Build Docker Images
  • GitHub Check: Build E2E Public App Assets
  • GitHub Check: Build Admin
  • GitHub Check: Unit tests (Node 22.23.1)
  • GitHub Check: Acceptance tests (Node 22.23.1, mysql8)
  • GitHub Check: Legacy tests (Node 22.23.1, better-sqlite3)
  • GitHub Check: Check app version bump
  • GitHub Check: Check migration integrity
  • GitHub Check: Acceptance tests (Node 22.23.1, better-sqlite3)
  • GitHub Check: Legacy tests (Node 22.23.1, mysql8)
  • GitHub Check: Lint
  • GitHub Check: i18n
  • GitHub Check: Detect Tinybird changes
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,cjs,mjs}

📄 CodeRabbit inference engine (Custom checks)

**/*.{js,jsx,cjs,mjs}: New files are TypeScript: Fail if the PR adds a new .js/.jsx/.cjs/.mjs source file, unless it is: a DB
migration (ghost/core/core/server/data/migrations/), under apps/ember-admin/,
a tool/config file, under scripts/ or docker/, or generated/vendored code.
Modifying pre-existing JS files never fails this check.

Files:

  • ghost/core/core/frontend/helpers/navigation.js
  • ghost/core/test/unit/frontend/helpers/navigation.test.js

⚙️ CodeRabbit configuration file

**/*.{js,jsx,cjs,mjs}: New source files must be TypeScript: flag new JS files as a required change
unless exempt (DB migrations, apps/ember-admin/, tool/config files, scripts/,
docker/, generated code).
Never request conversion of pre-existing JS files. If the PR substantially
reworks one (rewritten logic or significant new functions — not renames or
small fixes), you may leave ONE optional, non-blocking note for the whole PR
that those files are cheap TS-conversion candidates; skip minor changes and
exempt areas.
If the PR adds or changes a runtime boundary (parsing HTTP input, JSON, config,
external responses), suggest validating it — ideally with TS + Zod.

Files:

  • ghost/core/core/frontend/helpers/navigation.js
  • ghost/core/test/unit/frontend/helpers/navigation.test.js
**/*

📄 CodeRabbit inference engine (AGENTS.md)

Always use pnpm, never npm or Yarn.

Files:

  • ghost/core/core/frontend/helpers/navigation.js
  • ghost/core/core/frontend/helpers/tpl/navigation.hbs
  • ghost/core/test/unit/frontend/helpers/navigation.test.js

⚙️ CodeRabbit configuration file

**/*: Prioritise concrete correctness, security, data-integrity, compatibility,
and regression risks. Explain the failure mode and point to the affected
code. Do not report formatting, naming, import ordering, type errors, or
other findings already owned by configured static tools or failing GitHub
checks. Do not request speculative abstractions, broad refactors, generic
documentation, or tests unrelated to changed behaviour. Treat nearby
AGENTS.md files and mapped codebase documentation as authoritative; do not
enforce proposals, plans, or historical guidance as current policy.

Files:

  • ghost/core/core/frontend/helpers/navigation.js
  • ghost/core/core/frontend/helpers/tpl/navigation.hbs
  • ghost/core/test/unit/frontend/helpers/navigation.test.js
**/*{.,-}{test,spec}.{js,jsx,ts,tsx}

⚙️ CodeRabbit configuration file

**/*{.,-}{test,spec}.{js,jsx,ts,tsx}: Review whether tests prove changed behaviour, meaningful error/edge paths, and
externally observable contracts without coupling to implementation details.
Prefer the lowest useful test layer. Do not demand broad E2E coverage for
isolated logic or repeat test-run failures already visible in GitHub checks.

Files:

  • ghost/core/test/unit/frontend/helpers/navigation.test.js
🧠 Learnings (8)
📚 Learning: 2026-01-08T10:26:38.700Z
Learnt from: rob-ghost
Repo: TryGhost/Ghost PR: 25791
File: ghost/core/core/server/api/endpoints/member-comment-ban.js:64-68
Timestamp: 2026-01-08T10:26:38.700Z
Learning: In the Ghost API, endpoints rely on the serialization layer to prepare frame.data[docName] as a non-empty array before query() executes. Endpoints access frame.data[docName][0] directly (e.g., frame.data.comment_bans[0], frame.data.members[0], frame.data.posts[0]) without per-endpoint validation. This pattern is common across API endpoints. When maintaining or creating endpoints, avoid duplicating validation for frame.data[docName] and ensure the serializer guarantees the shape and non-emptiness. If you add a new endpoint that uses this frame.data[docName], follow the same assumption and avoid redundant checks unless there's a documented exception.

Applied to files:

  • ghost/core/core/frontend/helpers/navigation.js
  • ghost/core/test/unit/frontend/helpers/navigation.test.js
📚 Learning: 2026-02-04T15:58:09.124Z
Learnt from: rob-ghost
Repo: TryGhost/Ghost PR: 26219
File: ghost/core/test/e2e-api/members-comments/comments.test.js:939-983
Timestamp: 2026-02-04T15:58:09.124Z
Learning: In Ghost core tests and code that interact with the Ghost comments API, count.replies is a backward-compatible alias for count.total_replies (all descendants via parent_id) and does not represent direct replies. The new field count.direct_replies returns tree-native direct reply counts. Reviewers should verify any code paths, tests, or API surface areas that rely on count.replies are preserved for compatibility, and consider updating or adding tests to cover count.direct_replies for direct counts. When updating or adding tests, ensure behavior is documented and that any assertions reflect the distinction between total (including descendants) and direct reply counts to avoid regressions in API consumer expectations.

Applied to files:

  • ghost/core/core/frontend/helpers/navigation.js
  • ghost/core/test/unit/frontend/helpers/navigation.test.js
📚 Learning: 2026-04-09T09:44:26.783Z
Learnt from: vershwal
Repo: TryGhost/Ghost PR: 27290
File: ghost/core/package.json:76-77
Timestamp: 2026-04-09T09:44:26.783Z
Learning: In the TryGhost/Ghost monorepo, treat `tryghost/admin-api-schema` as the single abstraction layer over AJV version differences. Do not raise code review findings for AJV-internal error field changes (e.g., `dataPath` → `instancePath` between AJV v6 and v8) when evaluating Ghost consumer code. The consumer-facing error contract for this package (`ValidationError` with `message`, `property`, `errorDetails`) is expected to remain stable, and Ghost wrapper code should not inspect raw AJV error objects—so review should focus on the stable `ValidationError` shape rather than AJV internals.

Applied to files:

  • ghost/core/core/frontend/helpers/navigation.js
  • ghost/core/test/unit/frontend/helpers/navigation.test.js
📚 Learning: 2026-06-04T15:15:20.265Z
Learnt from: JohnONolan
Repo: TryGhost/Ghost PR: 28368
File: apps/admin-x-settings/src/components/settings/site/navigation/navigation-edit-form.tsx:32-32
Timestamp: 2026-06-04T15:15:20.265Z
Learning: In this TryGhost/Ghost codebase (Tailwind CSS v4), use/accept the v4 suffix form of the important modifier in class names (e.g., `opacity-100!`, `flex!`). Do not flag these as incorrect or inconsistent with the older v3 prefix form (`!opacity-100`), since the suffix form is the established convention and aligns with the generated CSS.

Applied to files:

  • ghost/core/core/frontend/helpers/navigation.js
  • ghost/core/test/unit/frontend/helpers/navigation.test.js
📚 Learning: 2026-06-22T14:36:35.803Z
Learnt from: sagzy
Repo: TryGhost/Ghost PR: 28779
File: ghost/core/core/frontend/web/middleware/error-handler.js:0-0
Timestamp: 2026-06-22T14:36:35.803Z
Learning: When using Express.js view engines, Express stores engine handler functions in `app.engines` with keys that include a leading dot (e.g., `app.engines['.hbs']` and `app.engines['.ejs']`). Therefore, checking `app.engines.hbs` (no dot) will be `undefined`; to test whether an engine is already registered, use bracket notation with the dot prefix: `app.engines['.hbs'] !== undefined` (or equivalently `Object.prototype.hasOwnProperty.call(app.engines, '.hbs')`).

Applied to files:

  • ghost/core/core/frontend/helpers/navigation.js
  • ghost/core/test/unit/frontend/helpers/navigation.test.js
📚 Learning: 2026-01-26T13:53:03.597Z
Learnt from: rob-ghost
Repo: TryGhost/Ghost PR: 25791
File: ghost/core/test/e2e-api/admin/member-commenting.test.js:268-321
Timestamp: 2026-01-26T13:53:03.597Z
Learning: In Ghost's e2e API tests, audit events should separate the generic operation from the specific action. Assert that event equals the CRUD operation type (e.g., 'edited', 'added', 'deleted') and, if needed, also assert on context.action_name for the exact action (e.g., 'commenting_disabled', 'commenting_enabled'). This makes tests robust to both high-level and specific audit details.

Applied to files:

  • ghost/core/test/unit/frontend/helpers/navigation.test.js
📚 Learning: 2026-03-12T10:43:01.366Z
Learnt from: vershwal
Repo: TryGhost/Ghost PR: 26791
File: ghost/core/test/unit/server/services/media-inliner/test/external-media-inliner.test.js:1033-1039
Timestamp: 2026-03-12T10:43:01.366Z
Learning: In tests for the Ghost media-inliner, when reviews reference getMediaStorage withArgs(extension), verify that the extension corresponds to the actual binary content of the nock/mocked response (detected via magic bytes) rather than the URL filename. This applies to all tests under ghost/core/test/unit/server/services/media-inliner (and similar media-inliner tests). Use binary content to determine expected extension (e.g., a GIF blob should yield .gif even if the URL ends with .jpg).

Applied to files:

  • ghost/core/test/unit/frontend/helpers/navigation.test.js
📚 Learning: 2026-05-12T19:57:42.468Z
Learnt from: ErisDS
Repo: TryGhost/Ghost PR: 27834
File: ghost/core/test/unit/frontend/helpers/social-accounts.test.js:51-69
Timestamp: 2026-05-12T19:57:42.468Z
Learning: In TryGhost/Ghost, Ghost’s helper wrapper (`helpers.registerHelper()` in `ghost/core/core/frontend/services/helpers`) is idempotent and will silently skip registration if a helper with the same name already exists. When writing tests and you need to override an existing Handlebars helper (e.g., stub `url`), register the helper directly on the Handlebars engine instance via `handlebars.registerHelper()` instead of using Ghost’s wrapper.

Applied to files:

  • ghost/core/test/unit/frontend/helpers/navigation.test.js
🔇 Additional comments (3)
ghost/core/core/frontend/helpers/navigation.js (1)

175-176: LGTM!

ghost/core/core/frontend/helpers/tpl/navigation.hbs (1)

3-3: LGTM!

ghost/core/test/unit/frontend/helpers/navigation.test.js (1)

330-331: LGTM!

Also applies to: 343-356


Walkthrough

The navigation helper now passes the navigationIcons Labs flag to the navigation template. The template renders icons and label spans when enabled, and direct label text when disabled. Unit tests cover disabled rendering, visibility filtering, paid items, and legacy markup.

Possibly related PRs

Suggested reviewers: johnonolan

Merge Risk: ⚪ Minimal · up to df4b4

This localized change restores the previous navigation markup when the icons flag is disabled and adds coverage for that behavior; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix to navigation markup when the icons flag is disabled.
Description check ✅ Passed The description directly explains the markup regression, the flag-gated fix, and the related tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Type-Safe Boundaries ✅ Passed The PR adds only the boolean result of internal labs.isSet to template data; it introduces no boundary payload, Zod-shape duplication, any, unchecked cast, or TypeScript bypass.
New Files Are Typescript ✅ Passed The diff adds no .js/.jsx/.cjs/.mjs files; both changed JavaScript paths existed at origin/main and are modified pre-existing files.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-navigation-tpl-flag-off

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit df4b40c

Command Status Duration Result
nx run ghost:test:ci:integration ✅ Succeeded 2m 48s View ↗
nx run ghost:test:integration ✅ Succeeded 3m 25s View ↗
nx run ghost:test:legacy ✅ Succeeded 3m 2s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 54s View ↗
nx run-many -t test:unit -p ghost ✅ Succeeded 34s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 21s View ↗
nx run-many -t lint -p ghost,ghost-monorepo ✅ Succeeded 18s View ↗
nx run @tryghost/admin:build ✅ Succeeded 4s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-19 18:33:32 UTC

@acburdine
acburdine enabled auto-merge (squash) August 19, 2026 18:25
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.26%. Comparing base (cef5922) to head (df4b40c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #30129      +/-   ##
==========================================
- Coverage   75.29%   75.26%   -0.04%     
==========================================
  Files        1622     1622              
  Lines      144885   144885              
  Branches    17948    17943       -5     
==========================================
- Hits       109086   109042      -44     
- Misses      34798    34846      +48     
+ Partials     1001      997       -4     
Flag Coverage Δ
e2e-tests 77.10% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@acburdine
acburdine merged commit 94e1321 into main Aug 19, 2026
54 checks passed
@acburdine
acburdine deleted the fix-navigation-tpl-flag-off branch August 19, 2026 18:35
acburdine added a commit that referenced this pull request Aug 19, 2026
no ref

Follow-up to #30129.

The navigation settings validator accepts an item with an icon and no
label regardless of the `navigationIcons` flag. So enabling the flag,
adding an icon-only item, then disabling the flag leaves the front end
rendering `<li class="nav-"><a href="/foo"></a></li>` — an empty,
unlabelled link, since the icon is dropped when the flag is off.

Before #28368 that data threw an `IncorrectUsageError`, which is the
worse option: it 500s the whole front end for data Admin allowed to be
saved. So items with nothing to render are now dropped instead, and a
nav where every item drops out renders nothing, matching the existing
empty-nav behaviour.

Note this also drops an item with a null label and no icon, which
previously rendered the same empty link. That shape is only reachable by
writing to the database directly — Admin has always required a label
(now label-or-icon).

Tests: an icon-only item is dropped while a sibling label item still
renders, and an all-icon-only nav renders an empty string. Flag-on
icon-only rendering is unchanged and still covered.
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