Skip to content

🐛 Fixed stale sidebar selections across Admin routes - #30334

Merged
9larsons merged 1 commit into
mainfrom
codex/des-1491-nav-selection
Aug 27, 2026
Merged

9larsons merged 1 commit into
mainfrom
codex/des-1491-nav-selection

Conversation

@peterzimon

Copy link
Copy Markdown
Contributor

Why

Navigating from an Ember-owned screen such as Posts or Pages to a React-owned screen could leave the old sidebar item selected. React Router uses pushState for React-owned routes, which intentionally preserves router history for navigation blockers but does not notify the Ember router. The Ember bridge therefore continued reporting its last route as active.

Fixes DES-1491.

What changed

  • Trust bridged Ember active-route state only while an Ember fallback is actually rendered.
  • Preserve the Link-versus-anchor navigation split introduced by Changed sidebar links to React-owned routes to navigate through the router #30122, including React Router history state and Ember hashchange navigation.
  • Cover Posts, Pages, saved views, and legacy Members Activity through the shared bridge boundary.
  • Explicitly select Analytics for /posts/analytics/*, matching the screen breadcrumb and product hierarchy.
  • Add regression coverage for stale Ember route state across React navigation.

Testing

  • pnpm test:unit src/ember-bridge/ember-bridge.test.tsx src/layout/app-sidebar/nav-custom-views.test.tsx

  • pnpm test:acceptance src/layout/sidebar.acceptance.test.tsx

  • pnpm test:acceptance src/posts/analytics/post-analytics.acceptance.test.tsx

  • pnpm typecheck

  • ESLint on all changed files

  • I have read and followed the Contributor Guide

  • I have explained my change

  • I have written automated tests to prove my change works

fixes https://linear.app/ghost/issue/DES-1491/posts-and-pages-selection-gets-stuck-in-nav-sidebar

React-owned navigation uses pushState, which leaves Ember's last route active. Trust bridged route state only while an Ember fallback is rendered so the sidebar follows the router that owns the current screen.
@nx-cloud

nx-cloud Bot commented Aug 27, 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 575d301

Command Status Duration Result
nx run @tryghost/admin:test:acceptance ✅ Succeeded 8m 7s View ↗
nx run-many -t test:unit -p @tryghost/admin ✅ Succeeded 1m 52s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 23s View ↗
nx run-many -t lint -p @tryghost/admin,ghost-mo... ✅ Succeeded 1m 23s View ↗
nx run @tryghost/admin:build ✅ Succeeded 23s View ↗
nx run @tryghost/e2e:test:fixtures ✅ Succeeded <1s 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-27 09:55:49 UTC

@coderabbitai

coderabbitai Bot commented Aug 27, 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: 937eb23d-77e5-4f0a-9589-a00e0400e71b

📥 Commits

Reviewing files that changed from the base of the PR and between 51d05ab and 575d301.

📒 Files selected for processing (6)
  • apps/admin/src/ember-bridge/ember-bridge.test.tsx
  • apps/admin/src/ember-bridge/ember-bridge.tsx
  • apps/admin/src/ember-bridge/index.ts
  • apps/admin/src/layout/app-sidebar/nav-main.tsx
  • apps/admin/src/layout/sidebar.acceptance.test.tsx
  • apps/admin/src/posts/analytics/post-analytics.acceptance.test.tsx

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

📜 Recent review details
⏰ Context from checks skipped due to timeout. (9)
  • GitHub Check: Build E2E Public App Assets
  • GitHub Check: App Playwright Acceptance Tests (@tryghost/admin)
  • GitHub Check: Build Admin
  • GitHub Check: Build Docker Images
  • GitHub Check: Stripe fixture checks
  • GitHub Check: Unit tests (Node 22.23.1)
  • GitHub Check: Lint
  • GitHub Check: Check app version bump
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (7)
Review Admin UI for existing Shade reuse, correct component layer, semantic

⚙️ CodeRabbit configuration file

Files:

  • apps/admin/src/posts/analytics/post-analytics.acceptance.test.tsx
  • apps/admin/src/ember-bridge/index.ts
  • apps/admin/src/layout/app-sidebar/nav-main.tsx
  • apps/admin/src/layout/sidebar.acceptance.test.tsx
  • apps/admin/src/ember-bridge/ember-bridge.tsx
  • apps/admin/src/ember-bridge/ember-bridge.test.tsx
Review whether tests prove changed behaviour, meaningful error/edge paths, and

⚙️ CodeRabbit configuration file

Files:

  • apps/admin/src/posts/analytics/post-analytics.acceptance.test.tsx
  • apps/admin/src/layout/sidebar.acceptance.test.tsx
  • apps/admin/src/ember-bridge/ember-bridge.test.tsx
Review lens: "where does this data become trusted?"

⚙️ CodeRabbit configuration file

Files:

  • apps/admin/src/posts/analytics/post-analytics.acceptance.test.tsx
  • apps/admin/src/ember-bridge/index.ts
  • apps/admin/src/layout/app-sidebar/nav-main.tsx
  • apps/admin/src/layout/sidebar.acceptance.test.tsx
  • apps/admin/src/ember-bridge/ember-bridge.tsx
  • apps/admin/src/ember-bridge/ember-bridge.test.tsx
Prioritise concrete correctness, security, data-integrity, compatibility,

⚙️ CodeRabbit configuration file

Files:

  • apps/admin/src/posts/analytics/post-analytics.acceptance.test.tsx
  • apps/admin/src/ember-bridge/index.ts
  • apps/admin/src/layout/app-sidebar/nav-main.tsx
  • apps/admin/src/layout/sidebar.acceptance.test.tsx
  • apps/admin/src/ember-bridge/ember-bridge.tsx
  • apps/admin/src/ember-bridge/ember-bridge.test.tsx
Type-safe boundaries: Fail only if the PR:

📄 CodeRabbit inference engine (Custom checks)

Files:

  • apps/admin/src/posts/analytics/post-analytics.acceptance.test.tsx
  • apps/admin/src/ember-bridge/index.ts
  • apps/admin/src/layout/app-sidebar/nav-main.tsx
  • apps/admin/src/layout/sidebar.acceptance.test.tsx
  • apps/admin/src/ember-bridge/ember-bridge.tsx
  • apps/admin/src/ember-bridge/ember-bridge.test.tsx
Build new features in React,

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/admin/src/posts/analytics/post-analytics.acceptance.test.tsx
  • apps/admin/src/ember-bridge/index.ts
  • apps/admin/src/layout/app-sidebar/nav-main.tsx
  • apps/admin/src/layout/sidebar.acceptance.test.tsx
  • apps/admin/src/ember-bridge/ember-bridge.tsx
  • apps/admin/src/ember-bridge/ember-bridge.test.tsx
Always use `pnpm`, never npm or Yarn.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/admin/src/posts/analytics/post-analytics.acceptance.test.tsx
  • apps/admin/src/ember-bridge/index.ts
  • apps/admin/src/layout/app-sidebar/nav-main.tsx
  • apps/admin/src/layout/sidebar.acceptance.test.tsx
  • apps/admin/src/ember-bridge/ember-bridge.tsx
  • apps/admin/src/ember-bridge/ember-bridge.test.tsx
🔇 Additional comments (6)
apps/admin/src/ember-bridge/ember-bridge.tsx (1)

1-4: LGTM!

Also applies to: 364-364, 390-395

apps/admin/src/ember-bridge/index.ts (1)

20-26: LGTM!

apps/admin/src/ember-bridge/ember-bridge.test.tsx (1)

419-431: LGTM!

Also applies to: 445-445, 455-456

apps/admin/src/layout/app-sidebar/nav-main.tsx (1)

9-9: LGTM!

Also applies to: 37-41, 54-57, 73-73

apps/admin/src/layout/sidebar.acceptance.test.tsx (1)

1-2: LGTM!

Also applies to: 34-55, 116-134

apps/admin/src/posts/analytics/post-analytics.acceptance.test.tsx (1)

18-18: LGTM!

Also applies to: 137-140


Walkthrough

The change guards Ember route activity with EmberContext and prevents stale Ember routes from remaining active after React navigation. The Analytics sidebar link now checks both analytics routes explicitly. Network notification counts use formatted values. Tests cover bridge delegation, stale route cleanup, and post analytics sidebar state.

Suggested reviewers: 9larsons, jonatansberg

Merge Risk: ⚪ Minimal · up to 575d3

This change corrects stale sidebar selection across Admin navigation paths and adds targeted regression coverage; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing stale sidebar selections across Admin routes.
Description check ✅ Passed The description directly explains the stale sidebar issue, the implementation, affected routes, and regression 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 PASS. The PR does not introduce an unvalidated boundary read or a typing bypass. The new useContext(EmberContext) read uses an internal React context. StateBridge is an existing interface that the…
New Files Are Typescript ✅ Passed PASS. The pull request changes six pre-existing files. The parent revision contains every changed path, and the diff has no added, copied, or renamed paths. All changed files use .ts or .tsx extension…
Full details: Type-Safe Boundaries

Explanation

PASS. The PR does not introduce an unvalidated boundary read or a typing bypass. The new useContext(EmberContext) read uses an internal React context. StateBridge is an existing interface that the PR only re-exports. The changed networkNotificationCount value comes from getNotificationsCount(), which already normalizes the external JSON count to a number or 0 before the hook returns it. The added test code is exempt, and its satisfies StateBridge assertion is not an unchecked cast.

Full details: New Files Are Typescript

Explanation

PASS. The pull request changes six pre-existing files. The parent revision contains every changed path, and the diff has no added, copied, or renamed paths. All changed files use .ts or .tsx extensions. Therefore, the PR does not add a disallowed JavaScript source file.

✨ 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 codex/des-1491-nav-selection

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

@peterzimon
peterzimon requested a review from 9larsons August 27, 2026 09:47
@9larsons
9larsons merged commit bf98309 into main Aug 27, 2026
51 checks passed
@9larsons
9larsons deleted the codex/des-1491-nav-selection branch August 27, 2026 11:59
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