Skip to content

Commit

Permalink
Set min-width on header section items only when they are not empty (#…
Browse files Browse the repository at this point in the history
…6158)

* Set min-width on header section items only when they are not empty

* Added the changelog

* Added the changelog

* Updated tests and snapshots

* Update upcoming_changelogs/6158.md

Co-authored-by: Elizabet Oliveira <elizabet.oliveira@elastic.co>

Co-authored-by: Elizabet Oliveira <elizabet.oliveira@elastic.co>
  • Loading branch information
yuliacech and miukimiu committed Aug 25, 2022
1 parent f5001b4 commit df5745d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
exports[`EuiHeaderSectionItem border defaults to left 1`] = `
<div
class="euiHeaderSectionItem euiHeaderSectionItem--borderLeft"
/>
>
<span>
Left is default
</span>
</div>
`;

exports[`EuiHeaderSectionItem border renders right 1`] = `
<div
class="euiHeaderSectionItem euiHeaderSectionItem--borderRight"
/>
>
<span>
Right section
</span>
</div>
`;

exports[`EuiHeaderSectionItem is rendered 1`] = `
<div
aria-label="aria-label"
class="euiHeaderSectionItem euiHeaderSectionItem--borderLeft testClass1 testClass2"
data-test-subj="test subject string"
/>
`;
exports[`EuiHeaderSectionItem is rendered 1`] = `null`;

exports[`EuiHeaderSectionItem renders children 1`] = `
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
display: none;
}
}
}
}
12 changes: 10 additions & 2 deletions src/components/header/header_section/header_section_item.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@ describe('EuiHeaderSectionItem', () => {

describe('border', () => {
test('defaults to left', () => {
const component = render(<EuiHeaderSectionItem />);
const component = render(
<EuiHeaderSectionItem>
<span>Left is default</span>
</EuiHeaderSectionItem>
);

expect(component).toMatchSnapshot();
});

test('renders right', () => {
const component = render(<EuiHeaderSectionItem border="right" />);
const component = render(
<EuiHeaderSectionItem border="right">
<span>Right section</span>
</EuiHeaderSectionItem>
);

expect(component).toMatchSnapshot();
});
Expand Down
5 changes: 3 additions & 2 deletions src/components/header/header_section/header_section_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ export const EuiHeaderSectionItem: FunctionComponent<EuiHeaderSectionItemProps>
className
);

return (
// we check if there is any children and if not, we don't render anything
return children ? (
<div className={classes} {...rest}>
{children}
</div>
);
) : null;
};
3 changes: 3 additions & 0 deletions upcoming_changelogs/6158.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Updated the `EuiHeaderSectionItem` to not render if empty

0 comments on commit df5745d

Please sign in to comment.