From 6ef6505e871ad5bd57b9cac8829df3b764567047 Mon Sep 17 00:00:00 2001 From: Paul Jankowski <8bittitan@gmail.com> Date: Wed, 28 Jan 2026 17:39:59 -0500 Subject: [PATCH] fix: Missing result title would trigger an error (#2852) --- packages/docsearch-react/src/Results.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/docsearch-react/src/Results.tsx b/packages/docsearch-react/src/Results.tsx index bff15a16..e4eff0c8 100644 --- a/packages/docsearch-react/src/Results.tsx +++ b/packages/docsearch-react/src/Results.tsx @@ -13,7 +13,7 @@ export type ResultsTranslations = Partial<{ }>; interface ResultsProps extends AutocompleteApi { - title: string; + title?: string | null; translations?: ResultsTranslations; collection: AutocompleteState['collections'][0]; renderIcon: (props: { item: TItem; index: number }) => React.ReactNode; @@ -25,7 +25,12 @@ interface ResultsProps export function Results(props: ResultsProps): JSX.Element | null { // The collection title, decoded to handle encoded HTML entities + // If there is not a title, return null to not render anything const decodedTitle = React.useMemo(() => { + if (!props.title) { + return null; + } + return props.title .replace(/&/g, '&') .replace(/</g, '<')