"Try searching for" no-results suggestions never render in v4 (searchSuggestions built as an object, consumed as an array)
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- react, typescript
Research direction
Read DocSearchModal.tsx to inspect how searchSuggestions is built, then compare it with the string[] usage in NoResultsScreen.tsx. Change the producer so suggestions remain an array and verify the no-results flow after first running a query with results, followed by a query with none; the “Try searching for” list should render.
Written by the indexing model from the issue text.
Description
Description
The "Try searching for" suggestions on the no-results screen never render in v4 (they did in v3). state.context.searchSuggestions is written as an object but consumed as an array, so NoResultsScreen's searchSuggestions.length > 0 guard is always false and the list is silently skipped.
Producer -- DocSearchModal.tsx (4.6.3 and main):
searchSuggestions: { ...(sourcesState.context.searchSuggestions ?? []), ...Object.keys(sources) }
// object-literal spread -> { 0: "...", 1: "..." }, not an array
Consumer -- NoResultsScreen.tsx (4.6.3 and main): typed string[], uses .length and .slice. v3 stored a plain array (searchSuggestions: Object.keys(sources)), which is why it worked there.
Fix: array spread instead of object spread (keeps the accumulate-across-searches intent):
searchSuggestions: [ ...(sourcesState.context.searchSuggestions ?? []), ...Object.keys(sources) ]
Steps to reproduce
- Open the DocSearch modal.
- Type a query that returns results (this populates the suggestions with the result group
lvl0s). - Type a query that returns no results.
- The "Try searching for:" list is missing (it appears in v3).
Expected behavior
The no-results screen shows the "Try searching for:" suggestions, as it does in v3.
Environment
- OS: any (code-path bug, not environment specific)
- Browser: any
- DocSearch version: 4.6.3 (same code on
main)
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 438
- Avg merge
- 17h 2m
- Merged PRs (30d)
- 15
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from algolia/docsearch
-
DocSearch v5 enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Needs investigation
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
algolia/docsearch#2863 · 4 comments · 2 reactions · 1 assignee ·
All issues in algolia/docsearch
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100