Skip to content

fix(ContentSearch): preserve intermediate ancestors in breadcrumb prefix#6466

Merged
benjamincanac merged 5 commits into
v4from
fix/content-search-breadcrumb-ancestors
May 20, 2026
Merged

fix(ContentSearch): preserve intermediate ancestors in breadcrumb prefix#6466
benjamincanac merged 5 commits into
v4from
fix/content-search-breadcrumb-ancestors

Conversation

@benjamincanac
Copy link
Copy Markdown
Member

@benjamincanac benjamincanac commented May 20, 2026

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

findNavItem only tracked the top-level root and the immediate parent, so any search result more than two nav levels deep silently dropped every ancestor in between. Searching nuxt plugins on nuxt.com rendered Docs > Best Practices > Nuxt Plugins instead of Docs > Guide > Best Practices > Nuxt Plugins.

  • Thread the full ancestor chain through both code paths: the async search results (mapSearchResults / findNavItem) and the static nav-walking path (mapNavigationItems / mapFile). For top-level matches (e.g. index pages), mapSearchResults falls back to the matched link so the section title still appears in flat results — mapFile doesn't, because those items render under their section's group label.
  • Icon fallback now walks ancestors closest-first so deep results inherit the nearest annotated section icon instead of always defaulting to the root.
  • Drive-by chore: close the content search modal when the user triggers the ⌘I chat shortcut, and drop a redundant "Ask AI" link description.

Verification

  • pnpm vitest run test/components/content/ContentSearch.spec.ts — all 17 tests pass, including the regression test at test/components/content/ContentSearch.spec.ts:177 for index-page prefixes.
  • Manual repro target: this repo's docs have one 4-level path (Getting Started > Integrations > i18n > Nuxt) that should now render with all four segments.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

`findNavItem` only tracked `root` + `parent`, so results more than two
levels deep silently dropped every nav node in between (e.g. `Docs >
Best Practices > Nuxt Plugins` instead of `Docs > Guide > Best Practices
> Nuxt Plugins`). Thread the full ancestor chain through both the
nav-walking path (`mapFile`/`mapNavigationItems`) and the async search
path (`mapSearchResults`), and fall back to the matched link when the
result lives at the section root so index pages still show their
section name. Icon fallback now walks ancestors closest-first so deep
results inherit the nearest annotated section icon.
When the search modal is open and the user presses `⌘I`, close search
and open chat instead of toggling chat behind it. Also drop the "Ask
AI" link description which duplicated context already conveyed by the
label + icon.
@github-actions github-actions Bot added the v4 #4488 label May 20, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 11335d41-8715-455c-9655-27fc5fc5e7af

📥 Commits

Reviewing files that changed from the base of the PR and between 23bb95f and 7ce74ae.

📒 Files selected for processing (1)
  • src/runtime/composables/useContentSearch.ts

📝 Walkthrough

Walkthrough

This PR refactors how content search tracks navigation context from a single parent/root reference to a full ancestor chain. findNavItem now returns both the matched navigation link and its complete ancestor lineage. mapFile, mapNavigationItems, and mapSearchResults build breadcrumb prefixes from all ancestor titles and apply updated icon precedence. A Vitest regression test verifies deep-prefix rendering. Chat.vue imports searchOpen and updates its meta_i shortcut to close search and open chat when search is active. The Ask AI link description was removed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main bug fix: preserving intermediate ancestors in breadcrumb prefixes for deeply nested search results.
Description check ✅ Passed The description comprehensively explains the bug, the solution approach, and includes verification steps, clearly relating 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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/content-search-breadcrumb-ancestors

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/runtime/composables/useContentSearch.ts

Parsing error: Unexpected token {


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 and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 20, 2026

npm i https://pkg.pr.new/@nuxt/ui@6466

commit: 7ce74ae

So future agents pick up the template at .github/PULL_REQUEST_TEMPLATE.md
when opening a PR instead of writing a free-form description.
Adds a 4-level nav regression test for `mapSearchResults` so the
intermediate-ancestor fix is locked in. Also swap the manual reverse-
then-find pattern for `Array#findLast` and drop a comment that
duplicates what the new method name now conveys.
Condense the prefix-related comments in `mapFile`, `findNavItem`, and
`mapSearchResults` to one line each. The asymmetry between the two
mappers is still called out, just more briefly.
@benjamincanac benjamincanac merged commit f639b19 into v4 May 20, 2026
24 checks passed
@benjamincanac benjamincanac deleted the fix/content-search-breadcrumb-ancestors branch May 20, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant