Skip to content

Commit 3513478

Browse files
fix(docsearch): update search suggestions when new lvl0s are encountered
1 parent 4f96cdb commit 3513478

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/DocSearch.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ export function DocSearch({
118118
openOnFocus: true,
119119
initialState: {
120120
query: initialQuery,
121+
context: {
122+
searchSuggestions: [],
123+
},
121124
},
122125
navigator,
123126
onStateChange({ state }) {
@@ -207,7 +210,10 @@ export function DocSearch({
207210

208211
// We store the `lvl0`s to display them as search suggestions
209212
// in the “no results“ screen.
210-
if (state.context.searchSuggestions === undefined) {
213+
if (
214+
(state.context.searchSuggestions as any[]).length <
215+
Object.keys(sources).length
216+
) {
211217
setContext({
212218
searchSuggestions: Object.keys(sources),
213219
});

0 commit comments

Comments
 (0)