fix(ContentSearch): preserve intermediate ancestors in breadcrumb prefix#6466
Conversation
`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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis 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)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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
src/runtime/composables/useContentSearch.tsParsing 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. Comment |
commit: |
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.
🔗 Linked issue
❓ Type of change
📚 Description
findNavItemonly tracked the top-levelrootand the immediateparent, so any search result more than two nav levels deep silently dropped every ancestor in between. Searchingnuxt pluginson nuxt.com renderedDocs > Best Practices > Nuxt Pluginsinstead ofDocs > Guide > Best Practices > Nuxt Plugins.mapSearchResults/findNavItem) and the static nav-walking path (mapNavigationItems/mapFile). For top-level matches (e.g. index pages),mapSearchResultsfalls back to the matched link so the section title still appears in flat results —mapFiledoesn't, because those items render under their section's group label.⌘Ichat 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.Getting Started > Integrations > i18n > Nuxt) that should now render with all four segments.📝 Checklist