ENG-3278: Improve nav search with keyword matching and relevance ranking#7952
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
There was a problem hiding this comment.
Nav Search Keyword Matching & Relevance Ranking
This is a clean, well-scoped improvement. The implementation is solid and the test coverage is thorough. A few notes:
Strengths
filterOption={false}(inline comment): Essential addition — without it, Ant Design'sAutoCompletewould double-filter results, silently discarding valid keyword/group matches. Easy to miss.- Relevance ranking design is sensible: title > parent > group > keyword, with stable ordering within each tier preserving nav-config source order. Using
Number.POSITIVE_INFINITYas the "no match" sentinel keeps the sort arithmetic clean. navMatchRankis self-contained — it normalizes the query internally (trim + lowercase), making it safe to call standalone without relying on callers to normalize first.- Test suite covers all the meaningful cases: empty query, case-insensitive matching per field, rank ordering, within-tier stability, and filtering. The
makeItemhelper keeps the tests readable. filterAndRankNavItemsuses a stable sort (JS Array.prototype.sort has been stable since ES2019 / V8 7.0), so the "preserves source order within rank" guarantee holds in all supported environments.
Minor observations
- The
if (!q) return 0guard innavMatchRankis dead code when called viafilterAndRankNavItems(callers gate onquery ?first), but it's correct for standalone use and makes the function safe to call in isolation — no action needed. - "Locations" and "Regulations" both carry
["GDPR", "CCPA"]keywords (see inline comment) — presumably intentional so both surface on those searches. - The keyword list in
nav-config.tsxwill naturally grow over time. If it becomes unwieldy, a co-locatedkeywordscomment block or a separatenav-keywords.tsconstant map could help, but that's a future concern.
No blocking issues. LGTM.
🔬 Codegraph: connected (46831 nodes)
💡 Write /code-review in a comment to re-run this review.
Code Review: ENG-3278 — Improve nav search with keyword matching and relevance rankingPR: #7952 🚨 Critical Issues (Must Fix)None. No blocking issues found. The implementation is clean, well-scoped, and correct.
|
Ticket ENG-3278
Description Of Changes
Enhances the admin UI nav search to support keyword/alias matching and multi-tier relevance ranking. Previously, only exact title substring matches surfaced results. Now, users can find pages by common synonyms (e.g. typing "TCF" finds "Vendors", "GDPR" finds "Locations" and "Regulations", "DSR" finds "Request manager").
Also fixes a bug where Ant Design's
AutoCompletewas applying its own built-in filter on top of our custom filtering, which silently dropped keyword matches from results.Code Changes
navMatchRank,matchesNavQuery, andfilterAndRankNavItemsutilities touseNavSearchItems.tswith a 4-tier relevance ranking (title > parent > group > keyword)keywordsfield toNavConfigRoute,NavConfigTab, andNavGroupChildinterfacesfilterOption={false}toAutoCompleteto prevent Ant's built-in filter from dropping keyword-matched resultsNavSearchExpandedandNavSearchModalto usefilterAndRankNavItemsinstead of simple title-only filteringSteps to Confirm
Pre-Merge Checklist
CHANGELOG.mdupdatedAdd a db-migration labelAdd a high-risk label