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)
Description
The "Try searching for" suggestions on the no-results screen never render in v4 (they did in v3).
state.context.searchSuggestionsis written as an object but consumed as an array, soNoResultsScreen'ssearchSuggestions.length > 0guard is always false and the list is silently skipped.Producer --
DocSearchModal.tsx(4.6.3 andmain):Consumer --
NoResultsScreen.tsx(4.6.3 andmain): typedstring[], uses.lengthand.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):
Steps to reproduce
lvl0s).Expected behavior
The no-results screen shows the "Try searching for:" suggestions, as it does in v3.
Environment
main)