fix(docsearch): update search suggestions when new lvl0s are encountered
This commit is contained in:
parent
4f96cdb622
commit
3513478fb6
1 changed files with 7 additions and 1 deletions
|
|
@ -118,6 +118,9 @@ export function DocSearch({
|
|||
openOnFocus: true,
|
||||
initialState: {
|
||||
query: initialQuery,
|
||||
context: {
|
||||
searchSuggestions: [],
|
||||
},
|
||||
},
|
||||
navigator,
|
||||
onStateChange({ state }) {
|
||||
|
|
@ -207,7 +210,10 @@ export function DocSearch({
|
|||
|
||||
// We store the `lvl0`s to display them as search suggestions
|
||||
// in the “no results“ screen.
|
||||
if (state.context.searchSuggestions === undefined) {
|
||||
if (
|
||||
(state.context.searchSuggestions as any[]).length <
|
||||
Object.keys(sources).length
|
||||
) {
|
||||
setContext({
|
||||
searchSuggestions: Object.keys(sources),
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue