Skip to content

Commit

Permalink
fix(TransitionablePortal): fix onClose call
Browse files Browse the repository at this point in the history
  • Loading branch information
mterezac committed Feb 15, 2022
1 parent ff70355 commit 1fe1aac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/addons/TransitionablePortal/TransitionablePortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,17 @@ export default class TransitionablePortal extends Component {
handleTransitionHide = (nothing, data) => {
debug('handleTransitionHide()')
const { portalOpen } = this.state
const { open } = this.props

this.setState({ transitionVisible: false })
_.invoke(this.props, 'onClose', null, { ...data, portalOpen: false, transitionVisible: false })

if (_.isUndefined(open) || open) {
_.invoke(this.props, 'onClose', null, {
...data,
portalOpen: false,
transitionVisible: false,
})
}
_.invoke(this.props, 'onHide', null, { ...data, portalOpen, transitionVisible: false })
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ describe('TransitionablePortal', () => {
}, done)
})

it('is not called if portal already closed ', () => {
const onClose = sandbox.spy()

wrapperMount(
<TransitionablePortal {...requiredProps} onClose={onClose} transition={quickTransition} />,
)

wrapper.setProps({ open: false })
onClose.should.not.have.been.called()
})

it('changes `portalOpen` to false', () => {
wrapperMount(
<TransitionablePortal
Expand Down

0 comments on commit 1fe1aac

Please sign in to comment.