diff --git a/public/app/features/search/components/SearchResults.test.tsx b/public/app/features/search/components/SearchResults.test.tsx index d23d85bfe10..31354d9c92e 100644 --- a/public/app/features/search/components/SearchResults.test.tsx +++ b/public/app/features/search/components/SearchResults.test.tsx @@ -53,4 +53,13 @@ describe('SearchResults', () => { expect(mockOnToggleSection).toHaveBeenCalledTimes(1); expect(mockOnToggleSection).toHaveBeenCalledWith(generalFolder); }); + + it('should not throw an error if the search results have an empty title', () => { + const mockOnToggleSection = jest.fn(); + const searchResultsEmptyTitle = searchResults.slice(); + searchResultsEmptyTitle[0].title = ''; + expect(() => { + setup({ results: searchResultsEmptyTitle, onToggleSection: mockOnToggleSection }); + }).not.toThrowError(); + }); }); diff --git a/public/app/features/search/components/SearchResults.tsx b/public/app/features/search/components/SearchResults.tsx index 078f56d3ce8..8bf2766e2b8 100644 --- a/public/app/features/search/components/SearchResults.tsx +++ b/public/app/features/search/components/SearchResults.tsx @@ -33,7 +33,9 @@ export const SearchResults: FC = memo( {results.map((section) => { return (
- + {section.title && ( + + )} {section.expanded && (
{section.items.map((item) => (