Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
}
}
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
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