Skip to content

Commit

Permalink
fix(docsearch): hide search suggestions if none
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Apr 4, 2020
1 parent f944f30 commit d7d6984
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/NoResultsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ interface NoResultsScreenProps
}

export function NoResultsScreen(props: NoResultsScreenProps) {
const searchSuggestions: string[] = props.state.context.searchSuggestions;

return (
<div className="DocSearch-NoResults">
<p className="DocSearch-Title">
No results for "<strong>{props.state.query}</strong>".
</p>

<p>
Try searching for{' '}
{(props.state.context.searchSuggestions as string[])
.slice(0, 3)
.reduce<React.ReactNode[]>(
{searchSuggestions.length > 0 && (
<p>
Try searching for{' '}
{searchSuggestions.slice(0, 3).reduce<React.ReactNode[]>(
(acc, search) => [
...acc,
acc.length > 0 ? ', ' : '',
Expand All @@ -46,8 +47,9 @@ export function NoResultsScreen(props: NoResultsScreenProps) {
],
[]
)}
&nbsp;...
</p>
&nbsp;...
</p>
)}

<p className="DocSearch-Help">
If you believe this query should return results,
Expand Down

0 comments on commit d7d6984

Please sign in to comment.