Skip to content

Commit

Permalink
Default closeIcon to close if closeIcon=true
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcarbs committed Nov 23, 2016
1 parent e526878 commit da00365
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/modules/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Modal extends Component {
closeIcon: PropTypes.oneOfType([
PropTypes.node,
PropTypes.object,
PropTypes.bool,
]),

/** A modal can reduce its complexity */
Expand Down Expand Up @@ -217,9 +218,11 @@ class Modal extends Component {
const portalProps = _.pick(unhandled, portalPropNames)
const ElementType = getElementType(Modal, this.props)

const closeIconName = closeIcon === true ? 'close' : closeIcon

const modalJSX = (
<ElementType {...rest} className={classes} style={{ marginTop }} ref={c => (this._modalNode = c)}>
{Icon.create(closeIcon, { onClick: this.handleClose })}
{Icon.create(closeIconName, { onClick: this.handleClose })}
{children}
</ElementType>
)
Expand Down
7 changes: 6 additions & 1 deletion test/specs/modules/Modal/Modal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,12 @@ describe('Modal', () => {
describe('closeIcon', () => {
it('is not present by default', () => {
wrapperMount(<Modal open>foo</Modal>)
assertBodyContains('.ui.modal .icon.bullseye', false)
assertBodyContains('.ui.modal .icon', false)
})

it('defaults to `close` when boolean', () => {
wrapperMount(<Modal open closeIcon>foo</Modal>)
assertBodyContains('.ui.modal .icon.close')
})

it('is present when passed', () => {
Expand Down

0 comments on commit da00365

Please sign in to comment.