mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: Don't show SectionHeader unless section has a title (#39336)
* Dashboard: Don't show SectionHeader unless section has a title * Dashboard: Add unit test to prevent regression
This commit is contained in:
parent
d116b2d71b
commit
06571e0af6
@ -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();
|
||||
});
|
||||
});
|
||||
|
@ -33,7 +33,9 @@ export const SearchResults: FC<Props> = memo(
|
||||
{results.map((section) => {
|
||||
return (
|
||||
<div aria-label={sectionLabel} className={styles.section} key={section.id || section.title}>
|
||||
<SectionHeader onSectionClick={onToggleSection} {...{ onToggleChecked, editable, section }} />
|
||||
{section.title && (
|
||||
<SectionHeader onSectionClick={onToggleSection} {...{ onToggleChecked, editable, section }} />
|
||||
)}
|
||||
{section.expanded && (
|
||||
<div aria-label={itemsLabel} className={styles.sectionItems}>
|
||||
{section.items.map((item) => (
|
||||
|
Loading…
Reference in New Issue
Block a user