Skip to content

Commit

Permalink
fix(ModalContent): Hide footer when no actions (patternfly#1167)
Browse files Browse the repository at this point in the history
Show the footer only if the actions array has content. Also made some
adjustments to ModalContent.test.js since some snapshots were blank, one
test had a typo, and some tests used a deprecated footer prop.

Fixes patternfly#1107
  • Loading branch information
rebeccaalpert authored and tlabaj committed Jan 11, 2019
1 parent 9381f04 commit a58a262
Show file tree
Hide file tree
Showing 3 changed files with 320 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const defaultProps = {

const ModalContent = ({ children, className, isOpen, title, hideTitle, actions, onClose, isLarge, id, ...props }) => {
const modalBoxHeader = title && <ModalBoxHeader> {title} </ModalBoxHeader>;
const modalBoxFooter = actions && <ModalBoxFooter> {actions} </ModalBoxFooter>;
const modalBoxFooter = actions.length > 0 && <ModalBoxFooter> {actions} </ModalBoxFooter>;
if (!isOpen) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ModalContent from './ModalContent';

test('Modal Content Test only body', () => {
const view = shallow(
<ModalContent title="Test Modal Content title" id="id">
<ModalContent title="Test Modal Content title" id="id" isOpen>
This is a ModalBox header
</ModalContent>
);
Expand All @@ -22,7 +22,7 @@ test('Modal Content Test isOpen', () => {

test('Modal Content Test with header', () => {
const view = shallow(
<ModalContent title="Test Modal Content title" id="id" header="Testing">
<ModalContent title="Test Modal Content title" id="id" isOpen header="Testing">
This is a ModalBox header
</ModalContent>
);
Expand All @@ -31,7 +31,16 @@ test('Modal Content Test with header', () => {

test('Modal Content Test with footer', () => {
const view = shallow(
<ModalContent title="Test Modal Content title" id="id" footer="Testing">
<ModalContent title="Test Modal Content title" id="id" isOpen actions={["Testing"]}>
This is a ModalBox header
</ModalContent>
);
expect(view).toMatchSnapshot();
});

test('Modal Content test without footer', () => {
const view = shallow(
<ModalContent title="Test Modal Content title" id="id" isOpen>
This is a ModalBox header
</ModalContent>
);
Expand All @@ -40,22 +49,23 @@ test('Modal Content Test with footer', () => {

test('Modal Content Test with header and footer', () => {
const view = shallow(
<ModalContent title="Test Modal Content title" header="Testing header" footer="Testing footer" id="id">
<ModalContent title="Test Modal Content title" header="Testing header" id="id" isOpen actions={["Testing footer"]}>
This is a ModalBox header
</ModalContent>
);
expect(view).toMatchSnapshot();
});

test('Modal Content Test with onlose', () => {
test('Modal Content Test with onclose', () => {
const view = shallow(
<ModalContent
title="Test Modal Content title"
header="Testing header"
footer="Testing footer"
actions={["Testing footer"]}
isLarge
onclose={() => undefined}
id="id"
isOpen
>
This is a ModalBox header
</ModalContent>
Expand Down
Loading

0 comments on commit a58a262

Please sign in to comment.