Skip to content

Commit

Permalink
Fix no results showing while there are results (#2719)
Browse files Browse the repository at this point in the history
  • Loading branch information
clairechabas authored Jan 10, 2025
1 parent 16194c5 commit 6059efe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-days-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gitbook': patch
---

Fix search no results error showing while there are results
4 changes: 2 additions & 2 deletions packages/gitbook/src/components/Search/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type ResultType =
* Fetch the results of the keyboard navigable elements to display for a query:
* - Recommended questions if no query is provided.
* - Search results if a query is provided.
* - If withAsk is true and the query is a question, add a question result.
* - If withAsk is true, add a question result.
*/
export const SearchResults = React.forwardRef(function SearchResults(
props: {
Expand Down Expand Up @@ -299,7 +299,7 @@ export const SearchResults = React.forwardRef(function SearchResults(
}
})}
</div>
{results.filter((result) => result.type === 'question').length > 0 && noResults}
{!results.some((result) => result.type !== 'question') && noResults}
</>
)}
</div>
Expand Down

0 comments on commit 6059efe

Please sign in to comment.