Skip to content

🐛 Fixed tag results in admin search not opening the tag - #30518

Merged
9larsons merged 1 commit into
mainfrom
slars/fix-search-tag-navigation
Sep 3, 2026
Merged

🐛 Fixed tag results in admin search not opening the tag#30518
9larsons merged 1 commit into
mainfrom
slars/fix-search-tag-navigation

Conversation

@9larsons

@9larsons 9larsons commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Clicking a tag in the Cmd-K search modal did nothing — the result was found and highlighted, but selecting it left you on the current screen.

Cause

gh-search-input.js navigates tag results by Ember route name:

if (selected.groupName === 'Tags') {
    let id = selected.id.replace('tag.', '');
    this.router.transitionTo('tag', id);
}

The Ember tag route aborts its transition when tagDetailsReact is on, so React can own /tags/:tagSlug. But an aborted transition never reaches updateURL, and the two apps share window.location.hash — so a transition Ember itself started leaves the hash untouched and React never navigates. A named intent is exactly the case with no URL of its own; a URL intent (cold load, React-driven navigation) already has the browser pointing at the right place.

tagDetailsReact is in GA_FEATURES, so this affects everyone.

Fix

Write the React URL for named intents, then park on the react-fallback catch-all — the same handling posts.js and lexical-editor.js already have behind their own flags. The tag route was the first flag-gated route and predates that handling; it was never backfilled.

Parking also keeps currentRouteName honest. Without it Ember still believes it is on the route it came from, so returning to the same tag URL later is compared against that stale route, found identical, and runs no transition at all.

/tags/new gets the same treatment via tag.new, which extends this route.

Tests

The existing search acceptance tests run with mirage labs {}, so tagDetailsReact is false there — they only covered the Ember-owned branch that no production user reaches, and would keep passing if this fix were reverted. Added tag-react-flag-test.js, which drives the real router with the flag on, mirroring the editor and posts equivalents. Reverting the fix fails 3 of its 6 tests.

Unit tests in tag-test.js cover the URL-intent vs named-intent split, tag.new, the parked-path guard, and URL/history-state restoration.

Verification

  • ember test --filter "tag" — 75 passing
  • ember test --filter "search" — 77 passing
  • ember test --filter "Unit: Route" — 13 passing
  • eslint app tests clean

Out of scope

Navigating away from a dirty React screen via any Ember-initiated hash write skips React's unsaved-changes blocker: the write creates a history entry with history.state === null, and isOnRouterHistoryEntry() returns false, so useBlocker declines. This is not introduced here — Ember's own HashLocation.setURL is this.location.hash = path, so Cmd-K results for Staff and the delete-tag-modal's /tags transition already behave this way. Worth a separate fix.

no ref

Clicking a tag in the Cmd-K search modal did nothing.

The Ember `tag` route aborts its transition when `tagDetailsReact` is on so
React can own the URL, but an aborted transition never reaches `updateURL` —
so a transition Ember itself started left the shared hash untouched and React
never rendered anything. The search modal navigates by route name
(`transitionTo('tag', slug)`), which is exactly the case that has no URL of
its own.

Write the React URL for named intents and park on `react-fallback`, matching
what the posts/pages and editor routes already do behind their own flags. The
tag route was the first flag-gated route and predates that handling. Parking
also keeps `currentRouteName` honest, so returning to the same tag URL later
is a real transition rather than a silent no-op.

The existing search acceptance tests run with mirage labs `{}`, so they only
covered the Ember-owned branch no production user reaches. The new acceptance
test drives the real router with the flag on, mirroring the editor and posts
equivalents.
@nx-cloud

nx-cloud Bot commented Sep 3, 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 d5f0d3e

Command Status Duration Result
nx run @tryghost/admin:test:acceptance ✅ Succeeded 10m 17s View ↗
nx run-many -t test:unit -p @tryghost/admin ✅ Succeeded 3m 54s View ↗
nx run ghost-admin:test ✅ Succeeded 2m 52s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 27s View ↗
nx run @tryghost/admin:build ✅ Succeeded 1m 58s View ↗
nx run-many -t lint -p ghost-admin,@tryghost/ad... ✅ Succeeded 1m 49s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded 1s View ↗
nx run @tryghost/e2e:test:fixtures ✅ Succeeded <1s View ↗

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


☁️ Nx Cloud last updated this comment at 2026-09-03 20:24:37 UTC

@coderabbitai

coderabbitai Bot commented Sep 3, 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: Team

Run ID: 415520bc-8a76-4e11-ada5-0d368fd2a2fc

📥 Commits

Reviewing files that changed from the base of the PR and between 736c33b and d5f0d3e.

📒 Files selected for processing (3)
  • apps/ember-admin/app/routes/tag.js
  • apps/ember-admin/tests/acceptance/tag-react-flag-test.js
  • apps/ember-admin/tests/unit/routes/tag-test.js

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

📜 Recent review details
⏰ Context from checks skipped due to timeout. (8)
  • GitHub Check: Unit tests (Node 22.23.1)
  • GitHub Check: Build Admin
  • GitHub Check: Admin tests - Chrome
  • GitHub Check: Unit tests (Node 24.20.0)
  • GitHub Check: App Playwright Acceptance Tests (@tryghost/admin)
  • GitHub Check: Build Docker Images
  • GitHub Check: Lint
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (5)
Review whether tests prove changed behaviour, meaningful error/edge paths, and externally observable contracts without coupling to implementation details.

⚙️ CodeRabbit configuration file

Files:

  • apps/ember-admin/tests/acceptance/tag-react-flag-test.js
  • apps/ember-admin/tests/unit/routes/tag-test.js
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).

⚙️ CodeRabbit configuration file

Files:

  • apps/ember-admin/tests/acceptance/tag-react-flag-test.js
  • apps/ember-admin/tests/unit/routes/tag-test.js
  • apps/ember-admin/app/routes/tag.js
Prioritise concrete correctness, security, data-integrity, compatibility, and regression risks.

⚙️ CodeRabbit configuration file

Files:

  • apps/ember-admin/tests/acceptance/tag-react-flag-test.js
  • apps/ember-admin/tests/unit/routes/tag-test.js
  • apps/ember-admin/app/routes/tag.js
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...

📄 CodeRabbit inference engine (Custom checks)

Files:

  • apps/ember-admin/tests/acceptance/tag-react-flag-test.js
  • apps/ember-admin/tests/unit/routes/tag-test.js
  • apps/ember-admin/app/routes/tag.js
Always use `pnpm`, never npm or Yarn.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/ember-admin/tests/acceptance/tag-react-flag-test.js
  • apps/ember-admin/tests/unit/routes/tag-test.js
  • apps/ember-admin/app/routes/tag.js
🧠 Learnings (1)
📚 Learning: 2026-08-24T15:30:14.342Z
Learnt from: aileen
Repo: TryGhost/Ghost PR: 30154
File: apps/ember-admin/tests/unit/services/state-bridge-subscription-test.js:1-55
Timestamp: 2026-08-24T15:30:14.342Z
Learning: In the Ghost repository, JavaScript test files under apps/ember-admin/tests/ are explicitly exempt from the “New files are TypeScript” check. Do not request conversion of these new test files to TypeScript because the Ember application has no TypeScript test pipeline.

Applied to files:

  • apps/ember-admin/tests/acceptance/tag-react-flag-test.js
  • apps/ember-admin/tests/unit/routes/tag-test.js
🔇 Additional comments (1)
apps/ember-admin/app/routes/tag.js (1)

63-63: 🎯 Functional Correctness

Cmd-K calls this.router.transitionTo('tag', id) and passes a string derived from selected.id, not a tag model. The reported model-transition failure does not apply.


Walkthrough

The tag route now leaves Ember in control when tagDetailsReact is not enabled. When enabled, it aborts the Ember transition, navigates to the matching React tag URL when needed, and parks the router on react-fallback while restoring the original URL and history state. Unit and acceptance tests cover existing tags, new tags, URL-initiated navigation, fallback routing, and repeated parking.

Merge Risk: ⚪ Minimal · up to d5f0d

With the feature enabled, tag navigation now delegates to the React tag pages while preserving URL and router state; the covered transition paths leave no concrete merge-blocking risk.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the tag navigation defect, its cause, the fix, test coverage, and verification. It directly matches the changeset.
Title check ✅ Passed The title clearly identifies the main change: fixing tag results in admin search so they open the tag. It is concise and related to the changeset.
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 adds navigation logic in an existing JavaScript route. It does not add any, unchecked as, @ts-nocheck, or @ts-ignore. The new route-parameter use checks that tag_slug is a strin…
New Files Are Typescript ✅ Passed The PR adds one new JavaScript file: apps/ember-admin/tests/acceptance/tag-react-flag-test.js. The custom check explicitly exempts all files under apps/ember-admin/. The other changed files are pr…
Full details: Type-Safe Boundaries

Explanation

PASS. The PR adds navigation logic in an existing JavaScript route. It does not add any, unchecked as, @ts-nocheck, or @ts-ignore. The new route-parameter use checks that tag_slug is a string before applying encodeURIComponent. The remaining values are Ember transition/router data and browser navigation state, not HTTP, API, configuration, database, filesystem, queue, or webhook payloads under this check. No duplicated type for a Zod schema was introduced.

Full details: New Files Are Typescript

Explanation

The PR adds one new JavaScript file: apps/ember-admin/tests/acceptance/tag-react-flag-test.js. The custom check explicitly exempts all files under apps/ember-admin/. The other changed files are pre-existing JavaScript files, so they do not trigger the check.

✨ 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 slars/fix-search-tag-navigation

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

@9larsons
9larsons enabled auto-merge (squash) September 3, 2026 20:17
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.48148% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.54%. Comparing base (736c33b) to head (d5f0d3e).

Files with missing lines Patch % Lines
apps/ember-admin/app/routes/tag.js 81.48% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #30518   +/-   ##
=======================================
  Coverage   67.53%   67.54%           
=======================================
  Files        1670     1670           
  Lines       60154    60179   +25     
  Branches    10403    10409    +6     
=======================================
+ Hits        40626    40648   +22     
- Misses      17237    17238    +1     
- Partials     2291     2293    +2     
Flag Coverage Δ
admin-tests 57.61% <81.48%> (+0.05%) ⬆️

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.

@9larsons
9larsons merged commit 4fbe5e3 into main Sep 3, 2026
55 checks passed
@9larsons
9larsons deleted the slars/fix-search-tag-navigation branch September 3, 2026 20:27
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